Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | List of all members
ola::network::TCPConnector Class Reference

Detailed Description

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.

Member Typedef Documentation

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.

The TCPConnectionID.

This can be used to cancel a pending TCP connection

Constructor & Destructor Documentation

ola::network::TCPConnector::TCPConnector ( ola::io::SelectServerInterface ss)
explicit

Create a new TCPConnector.

Parameters
ssThe SelectServerInterface to use

Member Function Documentation

bool ola::network::TCPConnector::Cancel ( TCPConnectionID  id)

Cancel a pending TCP connection.

Cancelling a connection causes the callback to be run with ETIMEDOUT.

Parameters
idthe id of the TCP connection to cancel
Returns
true if the connection was canceled. False if the TCPConnectionID wasn't found.
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.

Parameters
endpointthe IPV4SocketAddress to connect to
timeoutthe time to wait before declaring the connection a failure.
callbackthe TCPConnectCallback to run when the connection completes.
Returns
the TCPConnectionID for this connection, or 0 if the callback has already run.

The documentation for this class was generated from the following files: