##### basic_socket_acceptor::async_accept (1 of 8 overloads)

Start an asynchronous accept.

    template<
        typename Protocol1,
        typename Executor1,
        typename AcceptToken = DEFAULT>
    DEDUCED async_accept(
        basic_socket< Protocol1, Executor1 > & peer,
        AcceptToken && token = DEFAULT,
        typename constraint< is_convertible< Protocol, Protocol1 >::value >::type  = 0);

This function is used to asynchronously accept a new connection into a socket, and additionally obtain the endpoint of the remote peer. It is an initiating function for an asynchronous operation, and 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 completion handler is called.

token

  The completion token that will be used to produce a completion handler, which will be called when the accept completes. Potential completion tokens include `use_future`, `use_awaitable`, `yield_context`, or a function object with the correct completion signature. The function signature of the completion handler must be:

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

  Regardless of whether the asynchronous operation completes immediately or not, the completion 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`.

###### Completion Signature

    void(asio::error_code)

###### Example

    void accept_handler(const asio::error_code& error)
    {
      if (!error)
      {
        // Accept succeeded.
      }
    }

    ...

    asio::ip::tcp::acceptor acceptor(my_context);
    ...
    asio::ip::tcp::socket socket(my_context);
    acceptor.async_accept(socket, accept_handler);

###### Per-Operation Cancellation

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

- `cancellation_type::terminal`
- `cancellation_type::partial`
- `cancellation_type::total`