From b2448225328eaaf582e666fc8caeb442d11ee77d Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 25 Nov 2010 10:51:56 +0000 Subject: [PATCH] 2010-11-25 11:51 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rtl/hbinet.c * restored old behavior of listen sockets used by hb_inet*() functions for non Windows platforms (SO_REUSEADDR) --- harbour/ChangeLog | 5 +++++ harbour/src/rtl/hbinet.c | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4e34809072..b2c6b1fd0c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,11 @@ The license applies to all entries newer than 2009-04-28. */ +2010-11-25 11:51 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/src/rtl/hbinet.c + * restored old behavior of listen sockets used by hb_inet*() functions + for non Windows platforms (SO_REUSEADDR) + 2010-11-25 10:39 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbplist + Enabled new rddbmcdx. diff --git a/harbour/src/rtl/hbinet.c b/harbour/src/rtl/hbinet.c index cb90b6aa0d..0f68318dc1 100644 --- a/harbour/src/rtl/hbinet.c +++ b/harbour/src/rtl/hbinet.c @@ -1103,6 +1103,14 @@ HB_FUNC( HB_INETIFINFO ) * Server Specific functions ****/ +static int s_inetBind( PHB_SOCKET_STRUCT socket, const void * pSockAddr, unsigned uiLen ) +{ +#if !defined( HB_OS_WIN ) + hb_socketSetReuseAddr( socket->sd, HB_TRUE ); +#endif + return hb_socketBind( socket->sd, pSockAddr, uiLen ); +} + HB_FUNC( HB_INETSERVER ) { PHB_SOCKET_STRUCT socket = HB_PARSOCKET( 2 ); @@ -1130,7 +1138,7 @@ HB_FUNC( HB_INETSERVER ) if( socket->remote ) hb_xfree( socket->remote ); if( !hb_socketInetAddr( &socket->remote, &socket->remotelen, szAddress, iPort ) || - hb_socketBind( socket->sd, socket->remote, socket->remotelen ) != 0 || + s_inetBind( socket, socket->remote, socket->remotelen ) != 0 || hb_socketListen( socket->sd, iListen ) != 0 ) { socket->iError = hb_socketGetError(); @@ -1284,7 +1292,7 @@ HB_FUNC( HB_INETDGRAMBIND ) hb_xfree( socket->remote ); if( !hb_socketInetAddr( &socket->remote, &socket->remotelen, szAddress, iPort ) || - hb_socketBind( socket->sd, socket->remote, socket->remotelen ) != 0 ) + s_inetBind( socket, socket->remote, socket->remotelen ) != 0 ) { socket->iError = hb_socketGetError(); hb_inetCloseSocket( socket );