A connect token is a completion
token for completion signature void(error_code)
.
A free function as a connect token:
void connect_handler( const asio::error_code& ec) { ... }
A connect token function object:
struct connect_handler { ... void operator()( const asio::error_code& ec) { ... } ... };
A lambda as a connect token:
socket.async_connect(..., [](const asio::error_code& ec) { ... });
A non-static class member function adapted to a connect token using std::bind()
:
void my_class::connect_handler( const asio::error_code& ec) { ... } ... socket.async_connect(..., std::bind(&my_class::connect_handler, this, std::placeholders::_1));
A non-static class member function adapted to a connect token using boost::bind()
:
void my_class::connect_handler( const asio::error_code& ec) { ... } ... socket.async_connect(..., boost::bind(&my_class::connect_handler, this, asio::placeholders::error));
Using use_future as a connect token:
std::future<void> f = socket.async_connect(..., asio::use_future); ... try { f.get(); } catch (const system_error& e) { ... }
Using use_awaitable as a connect token:
asio::awaitable<void> my_coroutine() { try { ... co_await socket.async_connect(..., asio::use_awaitable); ... } catch (const system_error& e) { ... } }