Asio Extensions
Additional functionality built on top of (Boost.)Asio
asioext::connect()

Functions

void asioext::connect (asio::ip::tcp::socket::lowest_layer_type &socket, asio::ip::tcp::resolver &resolver, const asio::ip::tcp::resolver::query &q)
 Establishes a socket connection by trying each endpoint of a resolved name. More...
 
void asioext::connect (asio::ip::tcp::socket::lowest_layer_type &socket, asio::ip::tcp::resolver &resolver, const asio::ip::tcp::resolver::query &q, error_code &ec)
 Establishes a socket connection by trying each endpoint of a name. More...
 
template<typename ComposedConnectHandler >
void_or_deduced asioext::async_connect (asio::ip::tcp::socket::lowest_layer_type &socket, asio::ip::tcp::resolver &resolver, const asio::ip::tcp::resolver::query &q, ComposedConnectHandler &&handler)
 Asynchronously establishe a socket connection by trying each endpoint of a resolved name. More...
 

Detailed Description

Function Documentation

◆ async_connect()

template<typename ComposedConnectHandler >
void_or_deduced asioext::async_connect ( asio::ip::tcp::socket::lowest_layer_type &  socket,
asio::ip::tcp::resolver &  resolver,
const asio::ip::tcp::resolver::query &  q,
ComposedConnectHandler &&  handler 
)

Asynchronously establishe a socket connection by trying each endpoint of a resolved name.

This function attempts to connect a socket by first resolving the given name (using the query and resolver arguments) and then trying each resolved endpoint (by calling the socket's connect member) until a connection is established (or we've run out of endpoints).

Parameters
socketThe socket to be connected. If the socket is already open, it will be closed.
resolverThe resolver to be used for our query.
qThe name to be resolved to a list of endpoints.
handlerThe handler to be called when the connect operation completes. The function signature of the handler must be:
void handler(
// Result of operation. if the sequence is empty, set to
// asio::error::not_found. Otherwise, contains the
// error from the last connection attempt.
const error_code& error,
// On success, an iterator denoting the successfully
// connected endpoint. Otherwise, the end iterator.
asio::ip::tcp::resolver::iterator iterator
);

◆ connect() [1/2]

void asioext::connect ( asio::ip::tcp::socket::lowest_layer_type &  socket,
asio::ip::tcp::resolver &  resolver,
const asio::ip::tcp::resolver::query &  q 
)

Establishes a socket connection by trying each endpoint of a resolved name.

This function attempts to connect a socket by first resolving the given name (using the query and resolver arguments) and then trying each resolved endpoint (by calling the socket's connect member) until a connection is established (or we've run out of endpoints).

Parameters
socketThe socket to be connected. If the socket is already open, it will be closed.
resolverThe resolver to be used for our query.
qThe name to be resolved to a list of endpoints.
Exceptions
asio::system_errorThrown on failure. If the sequence is empty, the associated error_code is asio::error::not_found. Otherwise, contains the error from the last connection attempt.

◆ connect() [2/2]

void asioext::connect ( asio::ip::tcp::socket::lowest_layer_type &  socket,
asio::ip::tcp::resolver &  resolver,
const asio::ip::tcp::resolver::query &  q,
error_code ec 
)

Establishes a socket connection by trying each endpoint of a name.

This function attempts to connect a socket by first resolving the given name (using the query and resolver arguments) and then trying each resolved endpoint (by calling the socket's connect member) until a connection is established (or we've run out of endpoints).

Parameters
socketThe socket to be connected. If the socket is already open, it will be closed.
resolverThe resolver to be used for our query.
qThe name to be resolved to a list of endpoints.
ecSet to indicate what error occurred, if any. If the sequence is empty, set to asio::error::not_found. Otherwise, contains the error from the last connection attempt.