wxsocketclientderived from include files <wx/socket.h> members
wxsocketclient::wxsocketclient
wxsocketclient::wxsocketclientwxsocketclient(wxsocketflags flags = wxsocket_none) constructor. parameters flags
wxsocketclient::~wxsocketclient~wxsocketclient() destructor. please see wxsocketbase::destroy.
wxsocketclient::connectbool connect(wxsockaddress& address, bool wait = true) bool connect(wxsockaddress& address, wxsockaddress& local, bool wait = true) connects to a server using the specified address. if wait is true, connect will wait until the connection completes. warning: this will block the gui. if wait is false, connect will try to establish the connection and return immediately, without blocking the gui. when used this way, even if connect returns false, the connection request can be completed later. to detect this, use waitonconnect, or catch wxsocket_connection events (for successful establishment) and wxsocket_lost events (for connection failure). parameters address
local
wait
return value returns true if the connection is established and no error occurs. if wait was true, and connect returns false, an error occurred and the connection failed. if wait was false, and connect returns false, you should still be prepared to handle the completion of this connection request, either with waitonconnect or by watching wxsocket_connection and wxsocket_lost events. see also wxsocketclient::waitonconnect, wxsocketbase::setnotify, wxsocketbase::notify
wxsocketclient::waitonconnectbool waitonconnect(long seconds = -1, long milliseconds = 0) wait until a connection request completes, or until the specified timeout elapses. use this function after issuing a call to connect with wait set to false. parameters seconds
millisecond
return value waitonconnect returns true if the connection request completes. this does not necessarily mean that the connection was successfully established; it might also happen that the connection was refused by the peer. use isconnected to distinguish between these two situations. if the timeout elapses, waitonconnect returns false. these semantics allow code like this:
// issue the connection request client->connect(addr, false); // wait until the request completes or until we decide to give up bool waitmore = true; while ( !client->waitonconnect(seconds, millis) && waitmore ) { // possibly give some feedback to the user, // and update waitmore as needed. } bool success = client->isconnected();see also wxsocketclient::connect, wxsocketbase::interruptwait, wxsocketbase::isconnected
|