X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b1a8a61082caeb85192182c9ad77993ba62cc8c2..99e839da3c9c40a3dac7cf1bb841d6459fcac1b0:/src/unix/gsocket.c?ds=sidebyside diff --git a/src/unix/gsocket.c b/src/unix/gsocket.c index c7b0d7cf49..dc6c7e5702 100644 --- a/src/unix/gsocket.c +++ b/src/unix/gsocket.c @@ -261,7 +261,10 @@ GSocket *GSocket_new(void) void GSocket_close(GSocket *socket) { _GSocket_Disable_Events(socket); +// gsockosx.c calls CFSocketInvalidate which closes the socket for us +#if !(defined(__DARWIN__) && (defined(__WXMAC__) || defined(__WXCOCOA__))) close(socket->m_fd); +#endif socket->m_fd = INVALID_SOCKET; } @@ -269,20 +272,12 @@ void GSocket_destroy(GSocket *socket) { assert(socket != NULL); - /* When using CFSocket we MUST invalidate before closing the fd */ -#ifdef __DARWIN__ - /* Per-socket GUI-specific cleanup */ - _GSocket_GUI_Destroy_Socket(socket); -#endif - /* Check that the socket is really shutdowned */ if (socket->m_fd != INVALID_SOCKET) GSocket_Shutdown(socket); -#ifndef __DARWIN__ /* Per-socket GUI-specific cleanup */ _GSocket_GUI_Destroy_Socket(socket); -#endif /* Destroy private addresses */ if (socket->m_local) @@ -488,6 +483,11 @@ 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.