#ifndef __GSOCKET_STANDALONE__
#include "wx/defs.h"
+#include "wx/private/gsocketiohandler.h"
#endif
#if defined(__VISAGECPP__)
int i;
m_fd = INVALID_SOCKET;
+ m_handler = NULL;
+
for (i=0;i<GSOCK_MAX_EVENT;i++)
{
m_cbacks[i] = NULL;
m_timeout = 10*60*1000;
/* 10 minutes * 60 sec * 1000 millisec */
m_establishing = false;
+ m_initialRecvBufferSize = -1;
+ m_initialSendBufferSize = -1;
assert(gs_gui_functions);
/* Per-socket GUI-specific initialization */
void GSocket::Close()
{
gs_gui_functions->Disable_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;
}
/* Per-socket GUI-specific cleanup */
gs_gui_functions->Destroy_Socket(this);
+ delete m_handler;
+
/* Destroy private addresses */
if (m_local)
GAddress_destroy(m_local);
#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)
{