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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
basic_socket_acceptor::async_accept (2 of 8 overloads)

Start an asynchronous accept.

template<
    typename Executor1,
    typename AcceptHandler = DEFAULT>
DEDUCED async_accept(
    basic_socket< protocol_type, Executor1 > & peer,
    endpoint_type & peer_endpoint,
    AcceptHandler && handler = DEFAULT);

This function is used to asynchronously accept a new connection into a socket, and additionally obtain the endpoint of the remote peer. The function call always returns immediately.

Parameters

peer

The socket into which the new connection will be accepted. Ownership of the peer object is retained by the caller, which must guarantee that it is valid until the handler is called.

peer_endpoint

An endpoint object into which the endpoint of the remote peer will be written. Ownership of the peer_endpoint object is retained by the caller, which must guarantee that it is valid until the handler is called.

handler

The handler to be called when the accept operation completes. Copies will be made of the handler as required. The function signature of the handler must be:

void handler(
  const boost::system::error_code& error // Result of operation.
);

Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. On immediate completion, invocation of the handler will be performed in a manner equivalent to using post.

Per-Operation Cancellation

On POSIX or Windows operating systems, this asynchronous operation supports cancellation for the following cancellation_type values:


PrevUpHomeNext