wxSocketClient::Connect() now honours the 'wait' parameter.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3581 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guillermo Rodriguez Garcia
1999-09-07 15:34:27 +00:00
parent 9bbd7ba3ea
commit 791b24c405

View File

@@ -29,6 +29,7 @@
#include <wx/string.h> #include <wx/string.h>
#include <wx/timer.h> #include <wx/timer.h>
#include <wx/utils.h> #include <wx/utils.h>
#include <wx/module.h>
#include <wx/log.h> #include <wx/log.h>
#include <stdlib.h> #include <stdlib.h>
@@ -38,7 +39,6 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// wxSocket headers // wxSocket headers
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include <wx/module.h>
#include <wx/sckaddr.h> #include <wx/sckaddr.h>
#include <wx/socket.h> #include <wx/socket.h>
@@ -375,7 +375,7 @@ wxSocketBase& wxSocketBase::WriteMsg(const char *buffer, wxUint32 nbytes)
msg.sig[2] = (char) 0xed; msg.sig[2] = (char) 0xed;
msg.sig[3] = (char) 0xfe; msg.sig[3] = (char) 0xfe;
msg.len[0] = (char) nbytes & 0xff; msg.len[0] = (char) nbytes & 0xff;
msg.len[1] = (char) (nbytes >> 8) & 0xff; msg.len[1] = (char) (nbytes >> 8) & 0xff;
msg.len[2] = (char) (nbytes >> 16) & 0xff; msg.len[2] = (char) (nbytes >> 16) & 0xff;
msg.len[3] = (char) (nbytes >> 24) & 0xff; msg.len[3] = (char) (nbytes >> 24) & 0xff;
@@ -871,8 +871,10 @@ wxSocketClient::~wxSocketClient()
// -------------------------------------------------------------- // --------------------------------------------------------------
// --------- wxSocketClient Connect functions ------------------- // --------- wxSocketClient Connect functions -------------------
// -------------------------------------------------------------- // --------------------------------------------------------------
bool wxSocketClient::Connect(wxSockAddress& addr_man, bool WXUNUSED(wait) ) bool wxSocketClient::Connect(wxSockAddress& addr_man, bool wait)
{ {
GSocketError err;
if (IsConnected()) if (IsConnected())
Close(); Close();
@@ -889,10 +891,26 @@ bool wxSocketClient::Connect(wxSockAddress& addr_man, bool WXUNUSED(wait) )
m_connected = FALSE; m_connected = FALSE;
// GRG: If wait == FALSE, then set the socket to
// nonblocking. I will set it back to blocking later,
// but I am not sure if this is really a good idea.
// IMO, all GSockets objects used in wxSocket should
// be non-blocking.
// --------------------------------
if (!wait)
GSocket_SetNonBlocking(m_socket, TRUE);
// Update the flags of m_socket. // Update the flags of m_socket.
SetFlags(m_flags); SetFlags(m_flags);
// Try to connect
GSocket_SetPeer(m_socket, addr_man.GetAddress()); GSocket_SetPeer(m_socket, addr_man.GetAddress());
if (GSocket_Connect(m_socket, GSOCK_STREAMED) != GSOCK_NOERROR) err = GSocket_Connect(m_socket, GSOCK_STREAMED);
if (!wait)
GSocket_SetNonBlocking(m_socket, FALSE);
if (err != GSOCK_NOERROR)
return FALSE; return FALSE;
// Enables bg events. // Enables bg events.