3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>async_connect (5 of 6 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_connect.html" title="async_connect">
9 <link rel="prev" href="overload4.html" title="async_connect (4 of 6 overloads)">
10 <link rel="next" href="overload6.html" title="async_connect (6 of 6 overloads)">
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="overload4.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../async_connect.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="overload6.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h4 class="title">
27 <a name="boost_asio.reference.async_connect.overload5"></a><a class="link" href="overload5.html" title="async_connect (5 of 6 overloads)">async_connect
28 (5 of 6 overloads)</a>
29 </h4></div></div></div>
31 (Deprecated: Use range overload.) Asynchronously establishes a socket connection
32 by trying each endpoint in a sequence.
34 <pre class="programlisting">template<
35 typename <a class="link" href="../Protocol.html" title="Protocol requirements">Protocol</a>,
36 typename <a class="link" href="../Executor1.html" title="Executor requirements">Executor</a>,
38 typename <a class="link" href="../ConnectCondition.html" title="Connect condition requirements">ConnectCondition</a>,
39 typename <a class="link" href="../IteratorConnectHandler.html" title="Iterator connect handler requirements">IteratorConnectHandler</a> = <a class="link" href="../asynchronous_operations.html#boost_asio.reference.asynchronous_operations.default_completion_tokens"><span class="emphasis"><em>DEFAULT</em></span></a>>
40 <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_connect(
41 basic_socket< Protocol, Executor > & s,
43 ConnectCondition connect_condition,
44 IteratorConnectHandler && handler = <a class="link" href="../asynchronous_operations.html#boost_asio.reference.asynchronous_operations.default_completion_tokens"><span class="emphasis"><em>DEFAULT</em></span></a>,
45 typename enable_if<!is_endpoint_sequence< Iterator >::value >::type * = 0);
48 This function attempts to connect a socket to one of a sequence of endpoints.
49 It does this by repeated calls to the socket's <code class="computeroutput">async_connect</code>
50 member function, once for each endpoint in the sequence, until a connection
51 is successfully established.
54 <a name="boost_asio.reference.async_connect.overload5.h0"></a>
55 <span class="phrase"><a name="boost_asio.reference.async_connect.overload5.parameters"></a></span><a class="link" href="overload5.html#boost_asio.reference.async_connect.overload5.parameters">Parameters</a>
57 <div class="variablelist">
58 <p class="title"><b></b></p>
59 <dl class="variablelist">
60 <dt><span class="term">s</span></dt>
62 The socket to be connected. If the socket is already open, it will
65 <dt><span class="term">begin</span></dt>
67 An iterator pointing to the start of a sequence of endpoints.
69 <dt><span class="term">connect_condition</span></dt>
72 A function object that is called prior to each connection attempt.
73 The signature of the function object must be:
75 <pre class="programlisting">bool connect_condition(
76 const boost::system::error_code& ec,
77 const typename Protocol::endpoint& next);
80 The <code class="computeroutput">ec</code> parameter contains the result from the most recent
81 connect operation. Before the first connection attempt, <code class="computeroutput">ec</code>
82 is always set to indicate success. The <code class="computeroutput">next</code> parameter
83 is the next endpoint to be tried. The function object should return
84 true if the next endpoint should be tried, and false if it should
88 <dt><span class="term">handler</span></dt>
91 The handler to be called when the connect operation completes. Copies
92 will be made of the handler as required. The function signature of
95 <pre class="programlisting">void handler(
96 // Result of operation. if the sequence is empty, set to
97 // boost::asio::error::not_found. Otherwise, contains the
98 // error from the last connection attempt.
99 const boost::system::error_code& error,
101 // On success, an iterator denoting the successfully
102 // connected endpoint. Otherwise, the end iterator.
107 Regardless of whether the asynchronous operation completes immediately
108 or not, the handler will not be invoked from within this function.
109 On immediate completion, invocation of the handler will be performed
110 in a manner equivalent to using <a class="link" href="../post.html" title="post"><code class="computeroutput">post</code></a>.
116 <a name="boost_asio.reference.async_connect.overload5.h1"></a>
117 <span class="phrase"><a name="boost_asio.reference.async_connect.overload5.remarks"></a></span><a class="link" href="overload5.html#boost_asio.reference.async_connect.overload5.remarks">Remarks</a>
120 This overload assumes that a default constructed object of type <code class="computeroutput">Iterator</code>
121 represents the end of the sequence. This is a valid assumption for iterator
122 types such as <code class="computeroutput">boost::asio::ip::tcp::resolver::iterator</code>.
125 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
126 <td align="left"></td>
127 <td align="right"><div class="copyright-footer">Copyright © 2003-2019 Christopher M. Kohlhoff<p>
128 Distributed under the Boost Software License, Version 1.0. (See accompanying
129 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>)
134 <div class="spirit-nav">
135 <a accesskey="p" href="overload4.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../async_connect.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="overload6.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>