...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Connect the stream to the specified endpoint asynchronously.
template< class ConnectHandler> DEDUCED async_connect( endpoint_type const& ep, ConnectHandler&& handler);
This function is used to asynchronously connect the underlying socket
to the specified remote endpoint. The function call always returns immediately.
The underlying socket is automatically opened if needed. An automatically
opened socket is not returned to the closed state upon failure. If the
timeout timer expires while the operation is outstanding, the operation
will be canceled and the completion handler will be invoked with the
error timeout
.
Name |
Description |
---|---|
|
The remote endpoint to which the underlying socket will be connected. Copies will be made of the endpoint object as required. |
|
The completion handler to invoke when the operation completes. The implementation takes ownership of the handler by performing a decay-copy. The equivalent function signature of the handler must be: void handler( error_code ec // Result of operation );
Regardless of whether the asynchronous operation completes
immediately or not, the handler will not be invoked from within
this function. Invocation of the handler will be performed
in a manner equivalent to using |