From 5a0b5afd2bf94bb9611ef336922f1d5e9f4c01a1 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 11 Jan 2004 16:54:39 +0000 Subject: [PATCH] Applied patch [ 849212 ] Sets SO_REUSEADDR flag on server sockets git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@25128 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/gsocket.c | 5 +++++ src/unix/gsocket.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/msw/gsocket.c b/src/msw/gsocket.c index dbdbe90fe6..d14313deaa 100644 --- a/src/msw/gsocket.c +++ b/src/msw/gsocket.c @@ -318,6 +318,11 @@ 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. diff --git a/src/unix/gsocket.c b/src/unix/gsocket.c index a248f1def2..fa9fb9875d 100644 --- a/src/unix/gsocket.c +++ b/src/unix/gsocket.c @@ -669,6 +669,11 @@ GSocketError GSocket_SetNonOriented(GSocket *sck) ioctl(sck->m_fd, FIONBIO, &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, * and retrieve the actual address bound. */