X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/60edcf453539716afa50f8350531634e45e697cd..6e1609b1e0784f299933742e02c58462df809acc:/src/unix/gsocket.cpp diff --git a/src/unix/gsocket.cpp b/src/unix/gsocket.cpp index 13a3b5b12c..0fbdcb3e35 100644 --- a/src/unix/gsocket.cpp +++ b/src/unix/gsocket.cpp @@ -20,6 +20,7 @@ #ifndef __GSOCKET_STANDALONE__ #include "wx/defs.h" +#include "wx/private/gsocketiohandler.h" #endif #if defined(__VISAGECPP__) @@ -520,6 +521,8 @@ GSocket::GSocket() int i; m_fd = INVALID_SOCKET; + m_handler = NULL; + for (i=0;iDisable_Events(this); - /* gsockosx.c calls CFSocketInvalidate which closes the socket for us */ -#if !(defined(__DARWIN__) && (defined(__WXMAC__) || defined(__WXCOCOA__))) - close(m_fd); -#endif + + /* When running on OS X, the gsockosx implementation of GSocketGUIFunctionsTable + will close the socket during Disable_Events. However, it will only do this + if it is being used. That is, it won't do it in a console program. To + ensure we get the right behavior, we have gsockosx set m_fd = INVALID_SOCKET + if it has closed the socket which indicates to us (at runtime, instead of + at compile time as this had been before) that the socket has already + been closed. + */ + if(m_fd != INVALID_SOCKET) + close(m_fd); m_fd = INVALID_SOCKET; } @@ -565,6 +577,8 @@ GSocket::~GSocket() /* Per-socket GUI-specific cleanup */ gs_gui_functions->Destroy_Socket(this); + delete m_handler; + /* Destroy private addresses */ if (m_local) GAddress_destroy(m_local); @@ -1007,6 +1021,11 @@ GSocketError GSocket::Connect(GSocketStream stream) #endif } + if (m_initialRecvBufferSize >= 0) + setsockopt(m_fd, SOL_SOCKET, SO_RCVBUF, (const char*)&m_initialRecvBufferSize, sizeof(m_initialRecvBufferSize)); + if (m_initialSendBufferSize >= 0) + setsockopt(m_fd, SOL_SOCKET, SO_SNDBUF, (const char*)&m_initialSendBufferSize, sizeof(m_initialSendBufferSize)); + // If a local address has been set, then we need to bind to it before calling connect if (m_local && m_local->m_addr) {