Open Lighting Architecture
0.9.2
|
An class which manages non-blocking TCP connects.
Classes | |
class | PendingTCPConnection |
Public Types | |
typedef ola::SingleUseCallback2< void, int, int > | TCPConnectCallback |
The callback run when a TCP connection request completes. | |
typedef const void * | TCPConnectionID |
The TCPConnectionID. |
Public Member Functions | |
TCPConnector (ola::io::SelectServerInterface *ss) | |
Create a new TCPConnector. | |
TCPConnectionID | Connect (const IPV4SocketAddress &endpoint, const ola::TimeInterval &timeout, TCPConnectCallback *callback) |
Perform a non-blocking TCP connect. | |
bool | Cancel (TCPConnectionID id) |
Cancel a pending TCP connection. | |
void | CancelAll () |
Cancel all pending TCP connections. | |
unsigned int | ConnectionsPending () const |
Return the number of pending connections. |
typedef ola::SingleUseCallback2<void, int, int> ola::network::TCPConnector::TCPConnectCallback |
The callback run when a TCP connection request completes.
The first argument passed to the callback is the FD or -1 if the connect() request failed. If the request failed, the second argument is errno.
typedef const void* ola::network::TCPConnector::TCPConnectionID |
The TCPConnectionID.
This can be used to cancel a pending TCP connection
|
explicit |
Create a new TCPConnector.
ss | The SelectServerInterface to use |
bool ola::network::TCPConnector::Cancel | ( | TCPConnectionID | id | ) |
Cancel a pending TCP connection.
Cancelling a connection causes the callback to be run with ETIMEDOUT.
id | the id of the TCP connection to cancel |
TCPConnector::TCPConnectionID ola::network::TCPConnector::Connect | ( | const IPV4SocketAddress & | endpoint, |
const ola::TimeInterval & | timeout, | ||
TCPConnectCallback * | callback | ||
) |
Perform a non-blocking TCP connect.
The callback may be run from within this method. Some platforms like *BSD won't return EINPROGRESS if the address is local.
endpoint | the IPV4SocketAddress to connect to |
timeout | the time to wait before declaring the connection a failure. |
callback | the TCPConnectCallback to run when the connection completes. |