#include </home/zeitlin/src/wx/github/interface/wx/socket.h>
Public Member Functions | |
wxSocketClient (wxSocketFlags flags=wxSOCKET_NONE) | |
Constructor. | |
virtual | ~wxSocketClient () |
Destructor. | |
virtual bool | Connect (const wxSockAddress &address, bool wait=true) |
Connects to a server using the specified address. | |
bool | Connect (const wxSockAddress &address, const wxSockAddress &local, bool wait=true) |
Connects to a server using the specified address. | |
bool | WaitOnConnect (long seconds=-1, long milliseconds=0) |
Wait until a connection request completes, or until the specified timeout elapses. |
wxSocketClient::wxSocketClient | ( | wxSocketFlags | flags = wxSOCKET_NONE | ) |
Constructor.
flags | Socket flags (See wxSocketBase::SetFlags()) |
virtual wxSocketClient::~wxSocketClient | ( | ) | [virtual] |
Destructor.
Please see wxSocketBase::Destroy().
virtual bool wxSocketClient::Connect | ( | const wxSockAddress & | address, |
bool | wait = true |
||
) | [virtual] |
Connects to a server using the specified address.
If wait is true, Connect() will wait until the connection completes.
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).
address | Address of the server. |
wait | If true, waits for the connection to complete. |
Reimplemented in wxHTTP.
bool wxSocketClient::Connect | ( | const wxSockAddress & | address, |
const 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).
address | Address of the server. |
local | Bind to the specified local address and port before connecting. The local address and port can also be set using SetLocal(), and then using the 2-parameter Connect() method. |
wait | If true, waits for the connection to complete. |
bool wxSocketClient::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.
seconds | Number of seconds to wait. If -1, it will wait for the default timeout, as set with wxSocketBase::SetTimeout(). |
milliseconds | Number of milliseconds to wait. |
// 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();