1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>connect (9 of 12 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="../connect.html" title="connect"> 9<link rel="prev" href="overload8.html" title="connect (8 of 12 overloads)"> 10<link rel="next" href="overload10.html" title="connect (10 of 12 overloads)"> 11</head> 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> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="overload8.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../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="overload10.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="boost_asio.reference.connect.overload9"></a><a class="link" href="overload9.html" title="connect (9 of 12 overloads)">connect (9 28 of 12 overloads)</a> 29</h4></div></div></div> 30<p> 31 (Deprecated: Use range overload.) Establishes a socket connection by trying 32 each endpoint in a sequence. 33 </p> 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>, 37 typename Iterator, 38 typename <a class="link" href="../ConnectCondition.html" title="Connect condition requirements">ConnectCondition</a>> 39Iterator connect( 40 basic_socket< Protocol, Executor > & s, 41 Iterator begin, 42 ConnectCondition connect_condition, 43 typename enable_if<!is_endpoint_sequence< Iterator >::value >::type * = 0); 44</pre> 45<p> 46 This function attempts to connect a socket to one of a sequence of endpoints. 47 It does this by repeated calls to the socket's <code class="computeroutput">connect</code> member 48 function, once for each endpoint in the sequence, until a connection is 49 successfully established. 50 </p> 51<h6> 52<a name="boost_asio.reference.connect.overload9.h0"></a> 53 <span class="phrase"><a name="boost_asio.reference.connect.overload9.parameters"></a></span><a class="link" href="overload9.html#boost_asio.reference.connect.overload9.parameters">Parameters</a> 54 </h6> 55<div class="variablelist"> 56<p class="title"><b></b></p> 57<dl class="variablelist"> 58<dt><span class="term">s</span></dt> 59<dd><p> 60 The socket to be connected. If the socket is already open, it will 61 be closed. 62 </p></dd> 63<dt><span class="term">begin</span></dt> 64<dd><p> 65 An iterator pointing to the start of a sequence of endpoints. 66 </p></dd> 67<dt><span class="term">connect_condition</span></dt> 68<dd> 69<p> 70 A function object that is called prior to each connection attempt. 71 The signature of the function object must be: 72</p> 73<pre class="programlisting">bool connect_condition( 74 const boost::system::error_code& ec, 75 const typename Protocol::endpoint& next); 76</pre> 77<p> 78 The <code class="computeroutput">ec</code> parameter contains the result from the most recent 79 connect operation. Before the first connection attempt, <code class="computeroutput">ec</code> 80 is always set to indicate success. The <code class="computeroutput">next</code> parameter 81 is the next endpoint to be tried. The function object should return 82 true if the next endpoint should be tried, and false if it should 83 be skipped. 84 </p> 85</dd> 86</dl> 87</div> 88<h6> 89<a name="boost_asio.reference.connect.overload9.h1"></a> 90 <span class="phrase"><a name="boost_asio.reference.connect.overload9.return_value"></a></span><a class="link" href="overload9.html#boost_asio.reference.connect.overload9.return_value">Return Value</a> 91 </h6> 92<p> 93 On success, an iterator denoting the successfully connected endpoint. Otherwise, 94 the end iterator. 95 </p> 96<h6> 97<a name="boost_asio.reference.connect.overload9.h2"></a> 98 <span class="phrase"><a name="boost_asio.reference.connect.overload9.exceptions"></a></span><a class="link" href="overload9.html#boost_asio.reference.connect.overload9.exceptions">Exceptions</a> 99 </h6> 100<div class="variablelist"> 101<p class="title"><b></b></p> 102<dl class="variablelist"> 103<dt><span class="term">boost::system::system_error</span></dt> 104<dd><p> 105 Thrown on failure. If the sequence is empty, the associated <code class="computeroutput">error_code</code> 106 is <code class="computeroutput">boost::asio::error::not_found</code>. Otherwise, contains 107 the error from the last connection attempt. 108 </p></dd> 109</dl> 110</div> 111<h6> 112<a name="boost_asio.reference.connect.overload9.h3"></a> 113 <span class="phrase"><a name="boost_asio.reference.connect.overload9.remarks"></a></span><a class="link" href="overload9.html#boost_asio.reference.connect.overload9.remarks">Remarks</a> 114 </h6> 115<p> 116 This overload assumes that a default constructed object of type <code class="computeroutput">Iterator</code> 117 represents the end of the sequence. This is a valid assumption for iterator 118 types such as <code class="computeroutput">boost::asio::ip::tcp::resolver::iterator</code>. 119 </p> 120</div> 121<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 122<td align="left"></td> 123<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 124 Kohlhoff<p> 125 Distributed under the Boost Software License, Version 1.0. (See accompanying 126 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>) 127 </p> 128</div></td> 129</tr></table> 130<hr> 131<div class="spirit-nav"> 132<a accesskey="p" href="overload8.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../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="overload10.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 133</div> 134</body> 135</html> 136