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

Detailed Description

An class which manages non-blocking TCP connects.

Public Types

typedef
ola::SingleUseCallback2< void,
int, int > 
TCPConnectCallback
 The callback run when a TCP connection request completes. More...
 
typedef const void * TCPConnectionID
 The TCPConnectionID. More...
 

Public Member Functions

 TCPConnector (ola::io::SelectServerInterface *ss)
 Create a new TCPConnector. More...
 
TCPConnectionID Connect (const IPV4SocketAddress &endpoint, const ola::TimeInterval &timeout, TCPConnectCallback *callback)
 Perform a non-blocking TCP connect. More...
 
bool Cancel (TCPConnectionID id)
 Cancel a pending TCP connection. More...
 
void CancelAll ()
 Cancel all pending TCP connections.
 
unsigned int ConnectionsPending () const
 Return the number of pending connections.
 
void SocketWritable (class PendingTCPConnection *connection)
 Called when the TCP socket connects. More...
 

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.
void ola::network::TCPConnector::SocketWritable ( class PendingTCPConnection connection)

Called when the TCP socket connects.

Parameters
connectionthe connection that is now connected.

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