don't set SO_REUSEADDR by default; added GSocket_SetReuseAddr()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28463 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2004-07-25 12:40:10 +00:00
parent 8158e0e169
commit 7df69621d9
3 changed files with 26 additions and 17 deletions

View File

@@ -277,6 +277,7 @@ GSocketError GSocket_GetSockOpt(GSocket *socket, int level, int optname,
GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname,
const void *optval, int optlen);
GSocketError GSocket_SetReuseAddr(GSocket *socket);
void GSocket_Streamed(GSocket *socket);
void GSocket_Unstreamed(GSocket *socket);

View File

@@ -389,11 +389,6 @@ GSocketError GSocket_SetServer(GSocket *sck)
ioctlsocket(sck->m_fd, FIONBIO, (u_long FAR *) &arg);
_GSocket_Enable_Events(sck);
/* allow a socket to re-bind if the socket is in the TIME_WAIT
state after being previously closed.
*/
setsockopt(sck->m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(u_long));
/* Bind to the local address,
* retrieve the actual address bound,
* and listen up to 5 connections.
@@ -1010,6 +1005,15 @@ GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname,
return GSOCK_OPTERR;
}
GSocketError GSocket_SetReuseAddr(GSocket *socket)
{
/* allow a socket to re-bind if the socket is in the TIME_WAIT
state after being previously closed.
*/
u_long arg = 1;
setsockopt(socket->m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(u_long));
}
void GSocket_Streamed(GSocket *socket)
{
socket->m_stream = TRUE;

View File

@@ -483,11 +483,6 @@ GSocketError GSocket_SetServer(GSocket *sck)
#endif
_GSocket_Enable_Events(sck);
/* allow a socket to re-bind if the socket is in the TIME_WAIT
state after being previously closed.
*/
setsockopt(sck->m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(u_long));
/* Bind to the local address,
* retrieve the actual address bound,
* and listen up to 5 connections.
@@ -1149,6 +1144,15 @@ GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname,
return GSOCK_OPTERR;
}
GSocketError GSocket_SetReuseAddr(GSocket *socket)
{
/* allow a socket to re-bind if the socket is in the TIME_WAIT
state after being previously closed.
*/
u_long arg = 1;
setsockopt(socket->m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(u_long));
}
void GSocket_Streamed(GSocket *socket)
{
socket->m_stream = TRUE;