void *optval, int *optlen);
GSocketError SetSockOpt(int level, int optname,
const void *optval, int optlen);
+
+ void SetInitialSocketBuffers(int recv, int send)
+ {
+ m_initialRecvBufferSize = recv;
+ m_initialSendBufferSize = send;
+ }
+
protected:
GSocketError Input_Timeout();
GSocketError Output_Timeout();
int Send_Stream(const char *buffer, int size);
int Send_Dgram(const char *buffer, int size);
bool m_ok;
+ int m_initialRecvBufferSize;
+ int m_initialSendBufferSize;
/* TODO: Make these protected */
public:
bool WaitOnConnect(long seconds = -1, long milliseconds = 0);
+ // Sets initial socket buffer sizes using the SO_SNDBUF and SO_RCVBUF options
+ // before calling connect (either one can be -1 to leave it unchanged)
+ void SetInitialSocketBuffers(int recv, int send)
+ {
+ m_initialRecvBufferSize = recv;
+ m_initialSendBufferSize = send;
+ }
+
private:
- virtual bool DoConnect(wxSockAddress& addr, wxSockAddress* local, bool wait = true);
+ virtual bool
+ DoConnect(wxSockAddress& addr, wxSockAddress* local, bool wait = true);
+
+ // buffer sizes, -1 if unset and defaults should be used
+ int m_initialRecvBufferSize;
+ int m_initialSendBufferSize;
DECLARE_NO_COPY_CLASS(wxSocketClient)
};
const void *optval, int optlen);
virtual void Detected_Read();
virtual void Detected_Write();
+ void SetInitialSocketBuffers(int recv, int send)
+ {
+ m_initialRecvBufferSize = recv;
+ m_initialSendBufferSize = send;
+ }
+
protected:
void Enable(GSocketEvent event);
void Disable(GSocketEvent event);
int Send_Stream(const char *buffer, int size);
int Send_Dgram(const char *buffer, int size);
bool m_ok;
+ int m_initialRecvBufferSize;
+ int m_initialSendBufferSize;
public:
/* DFE: We can't protect these data member until the GUI code is updated */
/* protected: */
m_socket->SetLocal(la);
}
+#if defined(__WXMSW__) || defined(__WXGTK__)
+ m_socket->SetInitialSocketBuffers(m_initialRecvBufferSize, m_initialSendBufferSize);
+#endif
+
m_socket->SetPeer(addr_man.GetAddress());
err = m_socket->Connect(GSOCK_STREAMED);
m_reusable = false;
m_broadcast = false;
m_dobind = true;
-
+ m_initialRecvBufferSize = -1;
+ m_initialSendBufferSize = -1;
+
assert(gs_gui_functions);
/* Per-socket GUI-specific initialization */
m_ok = gs_gui_functions->Init_Socket(this);
setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(arg));
}
+ 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)
{
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 */
#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)
{