diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9d0c196085..a922b2ab68 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,17 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-09-01 11:33 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/hbsocket.c + ! added sock_init()/sock_exit() calls to DOS builds. + ! use select_s() and close_s() instead of select() and close() + in DOS builds. + + * harbour/contrib/hbnetio/netiocli.c + * harbour/contrib/hbnetio/netiosrv.c + ! initialize socket library automatically - it's necessary for some + platforms. + 2009-09-01 09:48 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbnetio/tests/netiotst.prg * check if NETIO server is properly started diff --git a/harbour/contrib/hbnetio/netiocli.c b/harbour/contrib/hbnetio/netiocli.c index 400575caf5..5252daf1dd 100644 --- a/harbour/contrib/hbnetio/netiocli.c +++ b/harbour/contrib/hbnetio/netiocli.c @@ -116,6 +116,9 @@ static char s_defaultServer[ NETIO_SERVERNAME_MAX ] = NETIO_DEFAULT_SERVER; static int s_defaultPort = NETIO_DEFAULT_PORT; static int s_defaultTimeOut = NETIO_DEFAULT_TIMEOUT; +static BOOL s_fInit = TRUE; + + static const HB_FILE_FUNCS * s_fileMethods( void ); static long s_fileRecvAll( PHB_CONCLI conn, void * buffer, long len ) @@ -433,14 +436,19 @@ static void s_netio_exit( void* cargo ) s_connections = conn->next; s_fileConFree( conn ); } + + if( s_fInit ) + { + hb_socketCleanup(); + s_fInit = TRUE; + } } static void s_netio_init( void ) { - static BOOL s_fInit = TRUE; - if( s_fInit ) { + hb_socketInit(); hb_fileRegister( s_fileMethods() ); hb_vmAtQuit( s_netio_exit, NULL ); s_fInit = FALSE; diff --git a/harbour/contrib/hbnetio/netiosrv.c b/harbour/contrib/hbnetio/netiosrv.c index fc11a152d5..8ecbf1c246 100644 --- a/harbour/contrib/hbnetio/netiosrv.c +++ b/harbour/contrib/hbnetio/netiosrv.c @@ -94,7 +94,6 @@ typedef struct _HB_LISTENSD } HB_LISTENSD, * PHB_LISTENSD; - static BOOL s_isDirSep( char c ) { /* intentionally used explicit values instead of harbour macros @@ -389,6 +388,8 @@ HB_FUNC( NETIO_SERVERSTOP ) HB_FUNC( NETIO_LISTEN ) { + static BOOL s_fInit = TRUE; + int iPort = hb_parnidef( 1, NETIO_DEFAULT_PORT ); const char * szAddress = hb_parc( 2 ); const char * szRootPath = hb_parc( 3 ); @@ -396,6 +397,12 @@ HB_FUNC( NETIO_LISTEN ) unsigned uiLen; HB_SOCKET sd = HB_NO_SOCKET; + if( s_fInit ) + { + hb_socketInit(); + s_fInit = FALSE; + } + if( hb_socketInetAddr( &pSockAddr, &uiLen, szAddress, iPort ) ) { sd = hb_socketOpen( HB_SOCKET_PF_INET, HB_SOCKET_PT_STREAM, 0 ); diff --git a/harbour/source/rtl/hbsocket.c b/harbour/source/rtl/hbsocket.c index 38fba6bb23..5fd88765a1 100644 --- a/harbour/source/rtl/hbsocket.c +++ b/harbour/source/rtl/hbsocket.c @@ -162,7 +162,9 @@ # include #else # include -# if defined( HB_OS_OS2 ) +# if defined( HB_OS_DOS ) +# include +# elif defined( HB_OS_OS2 ) # if defined( __WATCOMC__ ) # include # include @@ -181,6 +183,9 @@ # endif # include # include +# if defined( HB_OS_DOS ) +# define select select_s +# endif #endif #if defined( __CYGWIN__ ) @@ -715,6 +720,8 @@ int hb_socketInit( void ) #if defined( HB_OS_WIN ) WSADATA wsadata; ret = WSAStartup( HB_MKUSHORT( 1, 1 ), &wsadata ); +#elif defined( HB_OS_DOS ) + ret = sock_init(); #endif } HB_SOCKET_UNLOCK @@ -729,6 +736,8 @@ void hb_socketCleanup( void ) { #if defined( HB_OS_WIN ) WSACleanup(); +#elif defined( HB_OS_DOS ) + sock_exit(); #endif } HB_SOCKET_UNLOCK @@ -1945,6 +1954,8 @@ int hb_socketClose( HB_SOCKET sd ) hb_vmUnlock(); #if defined( HB_OS_WIN ) ret = closesocket( sd ); +#elif defined( HB_OS_DOS ) + ret = close_s( sd ); #else # if defined( EINTR ) /* ignoring EINTR in close() it's quite common bug when sockets or