1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>connect (4 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="overload3.html" title="connect (3 of 12 overloads)"> 10<link rel="next" href="overload5.html" title="connect (5 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="overload3.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="overload5.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.overload4"></a><a class="link" href="overload4.html" title="connect (4 of 12 overloads)">connect (4 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> 38Iterator connect( 39 basic_socket< Protocol, Executor > & s, 40 Iterator begin, 41 boost::system::error_code & ec, 42 typename enable_if<!is_endpoint_sequence< Iterator >::value >::type * = 0); 43</pre> 44<p> 45 This function attempts to connect a socket to one of a sequence of endpoints. 46 It does this by repeated calls to the socket's <code class="computeroutput">connect</code> member 47 function, once for each endpoint in the sequence, until a connection is 48 successfully established. 49 </p> 50<h6> 51<a name="boost_asio.reference.connect.overload4.h0"></a> 52 <span class="phrase"><a name="boost_asio.reference.connect.overload4.parameters"></a></span><a class="link" href="overload4.html#boost_asio.reference.connect.overload4.parameters">Parameters</a> 53 </h6> 54<div class="variablelist"> 55<p class="title"><b></b></p> 56<dl class="variablelist"> 57<dt><span class="term">s</span></dt> 58<dd><p> 59 The socket to be connected. If the socket is already open, it will 60 be closed. 61 </p></dd> 62<dt><span class="term">begin</span></dt> 63<dd><p> 64 An iterator pointing to the start of a sequence of endpoints. 65 </p></dd> 66<dt><span class="term">ec</span></dt> 67<dd><p> 68 Set to indicate what error occurred, if any. If the sequence is empty, 69 set to <code class="computeroutput">boost::asio::error::not_found</code>. Otherwise, contains 70 the error from the last connection attempt. 71 </p></dd> 72</dl> 73</div> 74<h6> 75<a name="boost_asio.reference.connect.overload4.h1"></a> 76 <span class="phrase"><a name="boost_asio.reference.connect.overload4.return_value"></a></span><a class="link" href="overload4.html#boost_asio.reference.connect.overload4.return_value">Return Value</a> 77 </h6> 78<p> 79 On success, an iterator denoting the successfully connected endpoint. Otherwise, 80 the end iterator. 81 </p> 82<h6> 83<a name="boost_asio.reference.connect.overload4.h2"></a> 84 <span class="phrase"><a name="boost_asio.reference.connect.overload4.remarks"></a></span><a class="link" href="overload4.html#boost_asio.reference.connect.overload4.remarks">Remarks</a> 85 </h6> 86<p> 87 This overload assumes that a default constructed object of type <code class="computeroutput">Iterator</code> 88 represents the end of the sequence. This is a valid assumption for iterator 89 types such as <code class="computeroutput">boost::asio::ip::tcp::resolver::iterator</code>. 90 </p> 91</div> 92<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 93<td align="left"></td> 94<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 95 Kohlhoff<p> 96 Distributed under the Boost Software License, Version 1.0. (See accompanying 97 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>) 98 </p> 99</div></td> 100</tr></table> 101<hr> 102<div class="spirit-nav"> 103<a accesskey="p" href="overload3.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="overload5.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 104</div> 105</body> 106</html> 107