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.
This commit is contained in:
Przemyslaw Czerpak
2009-09-01 09:34:26 +00:00
parent 875c946a57
commit 9c0e0b8969
4 changed files with 41 additions and 4 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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 );

View File

@@ -162,7 +162,9 @@
# include <ws2tcpip.h>
#else
# include <errno.h>
# if defined( HB_OS_OS2 )
# if defined( HB_OS_DOS )
# include <tcp.h>
# elif defined( HB_OS_OS2 )
# if defined( __WATCOMC__ )
# include <types.h>
# include <nerrno.h>
@@ -181,6 +183,9 @@
# endif
# include <unistd.h>
# include <fcntl.h>
# 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