2011-01-19 17:05 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/hbnetio/netiomt.prg
+ added 8-th parameter <sSrvFunc> to NETIO_MTSERVER().
It allows to set own server function which can be used for
statistic or connection INIT/EXIT code. By default it's
@netio_server() is used.
User functions may look like:
function custom_netio_server( pConnectionSocket )
register_connection( pConnectionSocket )
begin sequence
netio_server( pConnectionSocket )
finally
unregister_connection( pConnectionSocket )
end sequence
return nil
* harbour/contrib/hbnetio/netiosrv.c
+ added new server function
NETIO_SRVSOCKET( <pConnectionSocket> ) -> <pHbSocket>
<pHbSocket> can be used with Harbour socket functions (hb_socket*())
Please remember that <pHbSocket> handle can be used only for statistics
and must not be used for any send/receive operations.
* harbour/contrib/hbnetio/readme.txt
* updated
* harbour/contrib/hbwin/tests/olesrv1.prg
* modified to return HVM error object as OLE object to the client
on RTE
This commit is contained in:
@@ -16,6 +16,37 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2011-01-19 17:05 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/contrib/hbnetio/netiomt.prg
|
||||
+ added 8-th parameter <sSrvFunc> to NETIO_MTSERVER().
|
||||
It allows to set own server function which can be used for
|
||||
statistic or connection INIT/EXIT code. By default it's
|
||||
@netio_server() is used.
|
||||
User functions may look like:
|
||||
function custom_netio_server( pConnectionSocket )
|
||||
register_connection( pConnectionSocket )
|
||||
begin sequence
|
||||
netio_server( pConnectionSocket )
|
||||
finally
|
||||
unregister_connection( pConnectionSocket )
|
||||
end sequence
|
||||
return nil
|
||||
|
||||
* harbour/contrib/hbnetio/netiosrv.c
|
||||
+ added new server function
|
||||
NETIO_SRVSOCKET( <pConnectionSocket> ) -> <pHbSocket>
|
||||
<pHbSocket> can be used with Harbour socket functions (hb_socket*())
|
||||
Please remember that <pHbSocket> handle can be used only for statistics
|
||||
and must not be used for any send/receive operations.
|
||||
|
||||
* harbour/contrib/hbnetio/readme.txt
|
||||
* updated
|
||||
|
||||
* harbour/contrib/hbwin/tests/olesrv1.prg
|
||||
* modified to return HVM error object as OLE object to the client
|
||||
on RTE
|
||||
|
||||
|
||||
2011-01-19 07:21 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbexpra.c
|
||||
! fixed casting for C++ mode
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
* very simple TCP/IP file server with RPC support
|
||||
* All files which names starts 'net:' are redirected to this API.
|
||||
* This is code for simple MT server which is activated by:
|
||||
* NETIO_MTSERVER( [<nPort>], [<cIfAddr>], [<cRootDir>], [<lRPC>],
|
||||
* [<cPasswd>], [<nCompressionLevel>], [<nStrategy>] )
|
||||
* NETIO_MTSERVER( [<nPort>], [<cIfAddr>], [<cRootDir>], [<xRPC>],
|
||||
* [<cPasswd>], [<nCompressionLevel>], [<nStrategy>],
|
||||
* [<sSrvFunc>] )
|
||||
* -> <pListenSocket> | NIL
|
||||
* and can be stopped by:
|
||||
* NETIO_SERVERSTOP( <pListenSocket>, .T. )
|
||||
@@ -60,10 +61,16 @@
|
||||
|
||||
#include "error.ch"
|
||||
|
||||
FUNCTION NETIO_MTSERVER( nPort, cIfAddr, cRootDir, xRPC, ... )
|
||||
FUNCTION NETIO_MTSERVER( nPort, cIfAddr, cRootDir, xRPC, ;
|
||||
cPasswd, nCompressLevel, nStrategy, ;
|
||||
sSrvFunc )
|
||||
LOCAL pListenSocket, lRPC
|
||||
LOCAL oError
|
||||
|
||||
IF sSrvFunc == NIL
|
||||
sSrvFunc := @netio_server()
|
||||
ENDIF
|
||||
|
||||
IF hb_mtvm()
|
||||
SWITCH ValType( xRPC )
|
||||
CASE "S"
|
||||
@@ -72,12 +79,15 @@ FUNCTION NETIO_MTSERVER( nPort, cIfAddr, cRootDir, xRPC, ... )
|
||||
EXIT
|
||||
CASE "L"
|
||||
lRPC := xRPC
|
||||
EXIT
|
||||
OTHERWISE
|
||||
xRPC := NIL
|
||||
ENDSWITCH
|
||||
pListenSocket := netio_listen( nPort, cIfAddr, cRootDir, lRPC )
|
||||
IF !Empty( pListenSocket )
|
||||
hb_threadDetach( hb_threadStart( @netio_srvloop(), pListenSocket, xRPC, ... ) )
|
||||
hb_threadDetach( hb_threadStart( @netio_srvloop(), pListenSocket, ;
|
||||
xRPC, sSrvFunc, ;
|
||||
cPasswd, nCompressLevel, nStrategy ) )
|
||||
ENDIF
|
||||
ELSE
|
||||
oError := ErrorNew()
|
||||
@@ -96,7 +106,8 @@ FUNCTION NETIO_MTSERVER( nPort, cIfAddr, cRootDir, xRPC, ... )
|
||||
ENDIF
|
||||
RETURN pListenSocket
|
||||
|
||||
STATIC FUNCTION NETIO_SRVLOOP( pListenSocket, xRPC, ... )
|
||||
|
||||
STATIC FUNCTION NETIO_SRVLOOP( pListenSocket, xRPC, sSrvFunc, ... )
|
||||
LOCAL pConnectionSocket
|
||||
|
||||
WHILE .T.
|
||||
@@ -107,7 +118,7 @@ STATIC FUNCTION NETIO_SRVLOOP( pListenSocket, xRPC, ... )
|
||||
IF xRPC != NIL
|
||||
netio_rpcfilter( pConnectionSocket, xRPC )
|
||||
ENDIF
|
||||
hb_threadDetach( hb_threadStart( @netio_server(), pConnectionSocket ) )
|
||||
hb_threadDetach( hb_threadStart( sSrvFunc, pConnectionSocket ) )
|
||||
pConnectionSocket := NIL
|
||||
ENDDO
|
||||
RETURN NIL
|
||||
|
||||
@@ -1379,3 +1379,11 @@ HB_FUNC( NETIO_SRVSTATUS )
|
||||
}
|
||||
hb_retni( iStatus );
|
||||
}
|
||||
|
||||
HB_FUNC( NETIO_SRVSOCKET )
|
||||
{
|
||||
PHB_CONSRV conn = s_consrvParam( 1 );
|
||||
|
||||
if( conn )
|
||||
hb_socketItemPut( hb_stackReturnItem(), conn->sd );
|
||||
}
|
||||
|
||||
@@ -146,10 +146,16 @@ Server side functions:
|
||||
<sFuncSym> | <hValue> | NIL ) -> NIL
|
||||
NETIO_SERVERSTOP( <pListenSocket> | <pConnectionSocket> [, <lStop>] ) -> NIL
|
||||
NETIO_MTSERVER( [<nPort>], [<cIfAddr>], [<cRootDir>],
|
||||
[<lRPC> | <sFuncSym> | <hValue>],
|
||||
[<cPasswd>], [<nCompressionLevel>], [<nStrategy>] )
|
||||
[<xRPC> | <sFuncSym> | <hValue>],
|
||||
[<cPasswd>], [<nCompressionLevel>], [<nStrategy>],
|
||||
[<sSrvFunc>] )
|
||||
-> <pListenSocket>
|
||||
|
||||
NETIO_SRVSTATUS( <pConnectionSocket> [, <nStreamID>] ) -> <nStatus>
|
||||
NETIO_SRVSENDITEM( <pConnectionSocket>, <nStreamID>, <xData> ) -> <lSent>
|
||||
NETIO_SRVSENDDATA( <pConnectionSocket>, <nStreamID>, <cData> ) -> <lSent>
|
||||
|
||||
NETIO_SRVSOCKET( <pConnectionSocket> ) -> <pHbSocket>
|
||||
<pHbSocket> can be used with Harbour socket functions (hb_socket*())
|
||||
Please remember that <pHbSocket> handle can be used only for statistics
|
||||
and must not be used for any send/receive operations.
|
||||
|
||||
@@ -123,25 +123,38 @@ EXPORTED:
|
||||
ENDCLASS
|
||||
|
||||
METHOD Eval( cMethodName, ... ) CLASS OleNetioSrv
|
||||
LOCAL xRetVal, oErr
|
||||
|
||||
SWITCH cMethodName
|
||||
CASE "CONNECT"
|
||||
RETURN !Empty( ::pConn := NETIO_GETCONNECTION( ... ) )
|
||||
CASE "DISCONNECT"
|
||||
::pConn := NIL
|
||||
RETURN .T.
|
||||
CASE "PROCEXISTS"
|
||||
RETURN NETIO_PROCEXISTS( ::pConn, ... )
|
||||
CASE "PROCEXEC"
|
||||
RETURN NETIO_PROCEXEC( ::pConn, ... )
|
||||
CASE "PROCEXECW"
|
||||
RETURN NETIO_PROCEXECW( ::pConn, ... )
|
||||
CASE "FUNCEXEC"
|
||||
RETURN NETIO_FUNCEXEC( ::pConn, ... )
|
||||
ENDSWITCH
|
||||
BEGIN SEQUENCE WITH { |oErr| BREAK( oErr ) }
|
||||
SWITCH cMethodName
|
||||
CASE "CONNECT"
|
||||
xRetVal := !Empty( ::pConn := NETIO_GETCONNECTION( ... ) )
|
||||
EXIT
|
||||
CASE "DISCONNECT"
|
||||
::pConn := NIL
|
||||
xRetVal := .T.
|
||||
EXIT
|
||||
CASE "PROCEXISTS"
|
||||
xRetVal := NETIO_PROCEXISTS( ::pConn, ... )
|
||||
EXIT
|
||||
CASE "PROCEXEC"
|
||||
xRetVal := NETIO_PROCEXEC( ::pConn, ... )
|
||||
EXIT
|
||||
CASE "PROCEXECW"
|
||||
xRetVal := NETIO_PROCEXECW( ::pConn, ... )
|
||||
EXIT
|
||||
CASE "FUNCEXEC"
|
||||
xRetVal := NETIO_FUNCEXEC( ::pConn, ... )
|
||||
EXIT
|
||||
OTHERWISE
|
||||
/* redirect all other messages to RPC server as function calls */
|
||||
xRetVal := NETIO_FUNCEXEC( ::pConn, cMethodName, ... )
|
||||
ENDSWITCH
|
||||
RECOVER USING oErr
|
||||
xRetVal := oErr
|
||||
END SEQUENCE
|
||||
|
||||
/* redirect all other messages to RPC server as function calls */
|
||||
RETURN NETIO_FUNCEXEC( ::pConn, cMethodName, ... )
|
||||
RETURN xRetVal
|
||||
|
||||
|
||||
ANNOUNCE GT_SYS
|
||||
|
||||
Reference in New Issue
Block a user