Open Lighting Architecture: ola::network::TCPConnector Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
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.
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.
void | SocketWritable (class PendingTCPConnection *connection)
| Called when the TCP socket connects.

## Member Typedef Documentation

## ◆ TCPConnectCallback

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.

## ◆ TCPConnectionID

typedef const void* ola::network::TCPConnector::TCPConnectionID

The TCPConnectionID.

This can be used to cancel a pending TCP connection

## Constructor & Destructor Documentation

## ◆ TCPConnector()

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

Create a new TCPConnector.

Parameters

  ss | The SelectServerInterface to use

## Member Function Documentation

## ◆ Cancel()

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

Cancel a pending TCP connection.

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

Parameters

  id | the id of the TCP connection to cancel

Returns
  true if the connection was canceled. False if the TCPConnectionID wasn't found.

## ◆ Connect()

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

  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.

Returns
  the TCPConnectionID for this connection, or 0 if the callback has already run.

## ◆ SocketWritable()

void ola::network::TCPConnector::SocketWritable | ( | class PendingTCPConnection * | connection | ) |

Called when the TCP socket connects.

Parameters

  connection | the connection that is now connected.

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

- include/ola/network/TCPConnector.h
- common/network/TCPConnector.cpp