Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext
basic_stream::async_connect (1 of 5 overloads)

Connect the stream to the specified endpoint asynchronously.

Synopsis
template<
    class ConnectHandler = net::default_completion_token_t<executor_type>>
DEDUCED
async_connect(
    endpoint_type const& ep,
    ConnectHandler&& handler = net::default_completion_token_t< executor_type >{});
Description

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 error::timeout.

Parameters

Name

Description

ep

The remote endpoint to which the underlying socket will be connected. Copies will be made of the endpoint object as required.

handler

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 net::post.

See Also

async_connect


PrevUpHomeNext