3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>basic_socket_acceptor::async_accept (8 of 8 overloads)</title>
5 <link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../../../boost_asio.html" title="Boost.Asio">
8 <link rel="up" href="../async_accept.html" title="basic_socket_acceptor::async_accept">
9 <link rel="prev" href="overload7.html" title="basic_socket_acceptor::async_accept (7 of 8 overloads)">
10 <link rel="next" href="../async_wait.html" title="basic_socket_acceptor::async_wait">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="overload7.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../async_accept.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../boost_asio.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../async_wait.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h5 class="title">
27 <a name="boost_asio.reference.basic_socket_acceptor.async_accept.overload8"></a><a class="link" href="overload8.html" title="basic_socket_acceptor::async_accept (8 of 8 overloads)">basic_socket_acceptor::async_accept
28 (8 of 8 overloads)</a>
29 </h5></div></div></div>
31 Start an asynchronous accept.
33 <pre class="programlisting">template<
34 typename ExecutionContext,
35 typename <a class="link" href="../../MoveAcceptHandler.html" title="Move accept handler requirements">MoveAcceptHandler</a> = <a class="link" href="../../asynchronous_operations.html#boost_asio.reference.asynchronous_operations.default_completion_tokens"><span class="emphasis"><em>DEFAULT</em></span></a>>
36 <a class="link" href="../../asynchronous_operations.html#boost_asio.reference.asynchronous_operations.automatic_deduction_of_initiating_function_return_type"><span class="emphasis"><em>DEDUCED</em></span></a> async_accept(
37 ExecutionContext & context,
38 endpoint_type & peer_endpoint,
39 MoveAcceptHandler && handler = <a class="link" href="../../asynchronous_operations.html#boost_asio.reference.asynchronous_operations.default_completion_tokens"><span class="emphasis"><em>DEFAULT</em></span></a>,
40 typename enable_if< is_convertible< ExecutionContext &, execution_context & >::value >::type * = 0);
43 This function is used to asynchronously accept a new connection. The
44 function call always returns immediately.
47 This overload requires that the Protocol template parameter satisfy the
48 AcceptableProtocol type requirements.
51 <a name="boost_asio.reference.basic_socket_acceptor.async_accept.overload8.h0"></a>
52 <span class="phrase"><a name="boost_asio.reference.basic_socket_acceptor.async_accept.overload8.parameters"></a></span><a class="link" href="overload8.html#boost_asio.reference.basic_socket_acceptor.async_accept.overload8.parameters">Parameters</a>
54 <div class="variablelist">
55 <p class="title"><b></b></p>
56 <dl class="variablelist">
57 <dt><span class="term">context</span></dt>
59 The I/O execution context object to be used for the newly accepted
62 <dt><span class="term">peer_endpoint</span></dt>
64 An endpoint object into which the endpoint of the remote peer will
65 be written. Ownership of the peer_endpoint object is retained by
66 the caller, which must guarantee that it is valid until the handler
69 <dt><span class="term">handler</span></dt>
72 The handler to be called when the accept operation completes. Copies
73 will be made of the handler as required. The function signature
74 of the handler must be:
76 <pre class="programlisting">void handler(
77 const boost::system::error_code& error, // Result of operation.
78 typename Protocol::socket::template rebind_executor<
79 typename ExecutionContext::executor_type>::other peer
80 // On success, the newly accepted socket.
84 Regardless of whether the asynchronous operation completes immediately
85 or not, the handler will not be invoked from within this function.
86 On immediate completion, invocation of the handler will be performed
87 in a manner equivalent to using <a class="link" href="../../post.html" title="post"><code class="computeroutput">post</code></a>.
93 <a name="boost_asio.reference.basic_socket_acceptor.async_accept.overload8.h1"></a>
94 <span class="phrase"><a name="boost_asio.reference.basic_socket_acceptor.async_accept.overload8.example"></a></span><a class="link" href="overload8.html#boost_asio.reference.basic_socket_acceptor.async_accept.overload8.example">Example</a>
96 <pre class="programlisting">void accept_handler(const boost::system::error_code& error,
97 boost::asio::ip::tcp::socket peer)
107 boost::asio::ip::tcp::acceptor acceptor(my_context);
109 boost::asio::ip::tcp::endpoint endpoint;
110 acceptor.async_accept(my_context2, endpoint, accept_handler);
113 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
114 <td align="left"></td>
115 <td align="right"><div class="copyright-footer">Copyright © 2003-2019 Christopher M. Kohlhoff<p>
116 Distributed under the Boost Software License, Version 1.0. (See accompanying
117 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
122 <div class="spirit-nav">
123 <a accesskey="p" href="overload7.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../async_accept.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../boost_asio.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../async_wait.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>