Chris@16
|
1 //
|
Chris@16
|
2 // impl/connect.hpp
|
Chris@16
|
3 // ~~~~~~~~~~~~~~~~
|
Chris@16
|
4 //
|
Chris@101
|
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
Chris@16
|
6 //
|
Chris@16
|
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9 //
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_ASIO_IMPL_CONNECT_HPP
|
Chris@16
|
12 #define BOOST_ASIO_IMPL_CONNECT_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
15 # pragma once
|
Chris@16
|
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/asio/detail/bind_handler.hpp>
|
Chris@16
|
19 #include <boost/asio/detail/consuming_buffers.hpp>
|
Chris@16
|
20 #include <boost/asio/detail/handler_alloc_helpers.hpp>
|
Chris@16
|
21 #include <boost/asio/detail/handler_cont_helpers.hpp>
|
Chris@16
|
22 #include <boost/asio/detail/handler_invoke_helpers.hpp>
|
Chris@16
|
23 #include <boost/asio/detail/handler_type_requirements.hpp>
|
Chris@16
|
24 #include <boost/asio/detail/throw_error.hpp>
|
Chris@16
|
25 #include <boost/asio/error.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 #include <boost/asio/detail/push_options.hpp>
|
Chris@16
|
28
|
Chris@16
|
29 namespace boost {
|
Chris@16
|
30 namespace asio {
|
Chris@16
|
31
|
Chris@16
|
32 namespace detail
|
Chris@16
|
33 {
|
Chris@16
|
34 struct default_connect_condition
|
Chris@16
|
35 {
|
Chris@16
|
36 template <typename Iterator>
|
Chris@16
|
37 Iterator operator()(const boost::system::error_code&, Iterator next)
|
Chris@16
|
38 {
|
Chris@16
|
39 return next;
|
Chris@16
|
40 }
|
Chris@16
|
41 };
|
Chris@16
|
42 }
|
Chris@16
|
43
|
Chris@16
|
44 template <typename Protocol, typename SocketService, typename Iterator>
|
Chris@16
|
45 Iterator connect(basic_socket<Protocol, SocketService>& s, Iterator begin)
|
Chris@16
|
46 {
|
Chris@16
|
47 boost::system::error_code ec;
|
Chris@16
|
48 Iterator result = connect(s, begin, ec);
|
Chris@16
|
49 boost::asio::detail::throw_error(ec, "connect");
|
Chris@16
|
50 return result;
|
Chris@16
|
51 }
|
Chris@16
|
52
|
Chris@16
|
53 template <typename Protocol, typename SocketService, typename Iterator>
|
Chris@16
|
54 inline Iterator connect(basic_socket<Protocol, SocketService>& s,
|
Chris@16
|
55 Iterator begin, boost::system::error_code& ec)
|
Chris@16
|
56 {
|
Chris@16
|
57 return connect(s, begin, Iterator(), detail::default_connect_condition(), ec);
|
Chris@16
|
58 }
|
Chris@16
|
59
|
Chris@16
|
60 template <typename Protocol, typename SocketService, typename Iterator>
|
Chris@16
|
61 Iterator connect(basic_socket<Protocol, SocketService>& s,
|
Chris@16
|
62 Iterator begin, Iterator end)
|
Chris@16
|
63 {
|
Chris@16
|
64 boost::system::error_code ec;
|
Chris@16
|
65 Iterator result = connect(s, begin, end, ec);
|
Chris@16
|
66 boost::asio::detail::throw_error(ec, "connect");
|
Chris@16
|
67 return result;
|
Chris@16
|
68 }
|
Chris@16
|
69
|
Chris@16
|
70 template <typename Protocol, typename SocketService, typename Iterator>
|
Chris@16
|
71 inline Iterator connect(basic_socket<Protocol, SocketService>& s,
|
Chris@16
|
72 Iterator begin, Iterator end, boost::system::error_code& ec)
|
Chris@16
|
73 {
|
Chris@16
|
74 return connect(s, begin, end, detail::default_connect_condition(), ec);
|
Chris@16
|
75 }
|
Chris@16
|
76
|
Chris@16
|
77 template <typename Protocol, typename SocketService,
|
Chris@16
|
78 typename Iterator, typename ConnectCondition>
|
Chris@16
|
79 Iterator connect(basic_socket<Protocol, SocketService>& s,
|
Chris@16
|
80 Iterator begin, ConnectCondition connect_condition)
|
Chris@16
|
81 {
|
Chris@16
|
82 boost::system::error_code ec;
|
Chris@16
|
83 Iterator result = connect(s, begin, connect_condition, ec);
|
Chris@16
|
84 boost::asio::detail::throw_error(ec, "connect");
|
Chris@16
|
85 return result;
|
Chris@16
|
86 }
|
Chris@16
|
87
|
Chris@16
|
88 template <typename Protocol, typename SocketService,
|
Chris@16
|
89 typename Iterator, typename ConnectCondition>
|
Chris@16
|
90 inline Iterator connect(basic_socket<Protocol, SocketService>& s,
|
Chris@16
|
91 Iterator begin, ConnectCondition connect_condition,
|
Chris@16
|
92 boost::system::error_code& ec)
|
Chris@16
|
93 {
|
Chris@16
|
94 return connect(s, begin, Iterator(), connect_condition, ec);
|
Chris@16
|
95 }
|
Chris@16
|
96
|
Chris@16
|
97 template <typename Protocol, typename SocketService,
|
Chris@16
|
98 typename Iterator, typename ConnectCondition>
|
Chris@16
|
99 Iterator connect(basic_socket<Protocol, SocketService>& s,
|
Chris@16
|
100 Iterator begin, Iterator end, ConnectCondition connect_condition)
|
Chris@16
|
101 {
|
Chris@16
|
102 boost::system::error_code ec;
|
Chris@16
|
103 Iterator result = connect(s, begin, end, connect_condition, ec);
|
Chris@16
|
104 boost::asio::detail::throw_error(ec, "connect");
|
Chris@16
|
105 return result;
|
Chris@16
|
106 }
|
Chris@16
|
107
|
Chris@16
|
108 template <typename Protocol, typename SocketService,
|
Chris@16
|
109 typename Iterator, typename ConnectCondition>
|
Chris@16
|
110 Iterator connect(basic_socket<Protocol, SocketService>& s,
|
Chris@16
|
111 Iterator begin, Iterator end, ConnectCondition connect_condition,
|
Chris@16
|
112 boost::system::error_code& ec)
|
Chris@16
|
113 {
|
Chris@16
|
114 ec = boost::system::error_code();
|
Chris@16
|
115
|
Chris@16
|
116 for (Iterator iter = begin; iter != end; ++iter)
|
Chris@16
|
117 {
|
Chris@16
|
118 iter = connect_condition(ec, iter);
|
Chris@16
|
119 if (iter != end)
|
Chris@16
|
120 {
|
Chris@16
|
121 s.close(ec);
|
Chris@16
|
122 s.connect(*iter, ec);
|
Chris@16
|
123 if (!ec)
|
Chris@16
|
124 return iter;
|
Chris@16
|
125 }
|
Chris@16
|
126 }
|
Chris@16
|
127
|
Chris@16
|
128 if (!ec)
|
Chris@16
|
129 ec = boost::asio::error::not_found;
|
Chris@16
|
130
|
Chris@16
|
131 return end;
|
Chris@16
|
132 }
|
Chris@16
|
133
|
Chris@16
|
134 namespace detail
|
Chris@16
|
135 {
|
Chris@16
|
136 // Enable the empty base class optimisation for the connect condition.
|
Chris@16
|
137 template <typename ConnectCondition>
|
Chris@16
|
138 class base_from_connect_condition
|
Chris@16
|
139 {
|
Chris@16
|
140 protected:
|
Chris@16
|
141 explicit base_from_connect_condition(
|
Chris@16
|
142 const ConnectCondition& connect_condition)
|
Chris@16
|
143 : connect_condition_(connect_condition)
|
Chris@16
|
144 {
|
Chris@16
|
145 }
|
Chris@16
|
146
|
Chris@16
|
147 template <typename Iterator>
|
Chris@16
|
148 void check_condition(const boost::system::error_code& ec,
|
Chris@16
|
149 Iterator& iter, Iterator& end)
|
Chris@16
|
150 {
|
Chris@16
|
151 if (iter != end)
|
Chris@16
|
152 iter = connect_condition_(ec, static_cast<const Iterator&>(iter));
|
Chris@16
|
153 }
|
Chris@16
|
154
|
Chris@16
|
155 private:
|
Chris@16
|
156 ConnectCondition connect_condition_;
|
Chris@16
|
157 };
|
Chris@16
|
158
|
Chris@16
|
159 // The default_connect_condition implementation is essentially a no-op. This
|
Chris@16
|
160 // template specialisation lets us eliminate all costs associated with it.
|
Chris@16
|
161 template <>
|
Chris@16
|
162 class base_from_connect_condition<default_connect_condition>
|
Chris@16
|
163 {
|
Chris@16
|
164 protected:
|
Chris@16
|
165 explicit base_from_connect_condition(const default_connect_condition&)
|
Chris@16
|
166 {
|
Chris@16
|
167 }
|
Chris@16
|
168
|
Chris@16
|
169 template <typename Iterator>
|
Chris@16
|
170 void check_condition(const boost::system::error_code&, Iterator&, Iterator&)
|
Chris@16
|
171 {
|
Chris@16
|
172 }
|
Chris@16
|
173 };
|
Chris@16
|
174
|
Chris@16
|
175 template <typename Protocol, typename SocketService, typename Iterator,
|
Chris@16
|
176 typename ConnectCondition, typename ComposedConnectHandler>
|
Chris@16
|
177 class connect_op : base_from_connect_condition<ConnectCondition>
|
Chris@16
|
178 {
|
Chris@16
|
179 public:
|
Chris@16
|
180 connect_op(basic_socket<Protocol, SocketService>& sock,
|
Chris@16
|
181 const Iterator& begin, const Iterator& end,
|
Chris@16
|
182 const ConnectCondition& connect_condition,
|
Chris@16
|
183 ComposedConnectHandler& handler)
|
Chris@16
|
184 : base_from_connect_condition<ConnectCondition>(connect_condition),
|
Chris@16
|
185 socket_(sock),
|
Chris@16
|
186 iter_(begin),
|
Chris@16
|
187 end_(end),
|
Chris@16
|
188 start_(0),
|
Chris@16
|
189 handler_(BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler))
|
Chris@16
|
190 {
|
Chris@16
|
191 }
|
Chris@16
|
192
|
Chris@16
|
193 #if defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
194 connect_op(const connect_op& other)
|
Chris@16
|
195 : base_from_connect_condition<ConnectCondition>(other),
|
Chris@16
|
196 socket_(other.socket_),
|
Chris@16
|
197 iter_(other.iter_),
|
Chris@16
|
198 end_(other.end_),
|
Chris@16
|
199 start_(other.start_),
|
Chris@16
|
200 handler_(other.handler_)
|
Chris@16
|
201 {
|
Chris@16
|
202 }
|
Chris@16
|
203
|
Chris@16
|
204 connect_op(connect_op&& other)
|
Chris@16
|
205 : base_from_connect_condition<ConnectCondition>(other),
|
Chris@16
|
206 socket_(other.socket_),
|
Chris@16
|
207 iter_(other.iter_),
|
Chris@16
|
208 end_(other.end_),
|
Chris@16
|
209 start_(other.start_),
|
Chris@16
|
210 handler_(BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(other.handler_))
|
Chris@16
|
211 {
|
Chris@16
|
212 }
|
Chris@16
|
213 #endif // defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
214
|
Chris@16
|
215 void operator()(boost::system::error_code ec, int start = 0)
|
Chris@16
|
216 {
|
Chris@16
|
217 switch (start_ = start)
|
Chris@16
|
218 {
|
Chris@16
|
219 case 1:
|
Chris@16
|
220 for (;;)
|
Chris@16
|
221 {
|
Chris@16
|
222 this->check_condition(ec, iter_, end_);
|
Chris@16
|
223
|
Chris@16
|
224 if (iter_ != end_)
|
Chris@16
|
225 {
|
Chris@16
|
226 socket_.close(ec);
|
Chris@16
|
227 socket_.async_connect(*iter_,
|
Chris@16
|
228 BOOST_ASIO_MOVE_CAST(connect_op)(*this));
|
Chris@16
|
229 return;
|
Chris@16
|
230 }
|
Chris@16
|
231
|
Chris@16
|
232 if (start)
|
Chris@16
|
233 {
|
Chris@16
|
234 ec = boost::asio::error::not_found;
|
Chris@16
|
235 socket_.get_io_service().post(detail::bind_handler(*this, ec));
|
Chris@16
|
236 return;
|
Chris@16
|
237 }
|
Chris@16
|
238
|
Chris@16
|
239 default:
|
Chris@16
|
240
|
Chris@16
|
241 if (iter_ == end_)
|
Chris@16
|
242 break;
|
Chris@16
|
243
|
Chris@16
|
244 if (!socket_.is_open())
|
Chris@16
|
245 {
|
Chris@16
|
246 ec = boost::asio::error::operation_aborted;
|
Chris@16
|
247 break;
|
Chris@16
|
248 }
|
Chris@16
|
249
|
Chris@16
|
250 if (!ec)
|
Chris@16
|
251 break;
|
Chris@16
|
252
|
Chris@16
|
253 ++iter_;
|
Chris@16
|
254 }
|
Chris@16
|
255
|
Chris@16
|
256 handler_(static_cast<const boost::system::error_code&>(ec),
|
Chris@16
|
257 static_cast<const Iterator&>(iter_));
|
Chris@16
|
258 }
|
Chris@16
|
259 }
|
Chris@16
|
260
|
Chris@16
|
261 //private:
|
Chris@16
|
262 basic_socket<Protocol, SocketService>& socket_;
|
Chris@16
|
263 Iterator iter_;
|
Chris@16
|
264 Iterator end_;
|
Chris@16
|
265 int start_;
|
Chris@16
|
266 ComposedConnectHandler handler_;
|
Chris@16
|
267 };
|
Chris@16
|
268
|
Chris@16
|
269 template <typename Protocol, typename SocketService, typename Iterator,
|
Chris@16
|
270 typename ConnectCondition, typename ComposedConnectHandler>
|
Chris@16
|
271 inline void* asio_handler_allocate(std::size_t size,
|
Chris@16
|
272 connect_op<Protocol, SocketService, Iterator,
|
Chris@16
|
273 ConnectCondition, ComposedConnectHandler>* this_handler)
|
Chris@16
|
274 {
|
Chris@16
|
275 return boost_asio_handler_alloc_helpers::allocate(
|
Chris@16
|
276 size, this_handler->handler_);
|
Chris@16
|
277 }
|
Chris@16
|
278
|
Chris@16
|
279 template <typename Protocol, typename SocketService, typename Iterator,
|
Chris@16
|
280 typename ConnectCondition, typename ComposedConnectHandler>
|
Chris@16
|
281 inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
Chris@16
|
282 connect_op<Protocol, SocketService, Iterator,
|
Chris@16
|
283 ConnectCondition, ComposedConnectHandler>* this_handler)
|
Chris@16
|
284 {
|
Chris@16
|
285 boost_asio_handler_alloc_helpers::deallocate(
|
Chris@16
|
286 pointer, size, this_handler->handler_);
|
Chris@16
|
287 }
|
Chris@16
|
288
|
Chris@16
|
289 template <typename Protocol, typename SocketService, typename Iterator,
|
Chris@16
|
290 typename ConnectCondition, typename ComposedConnectHandler>
|
Chris@16
|
291 inline bool asio_handler_is_continuation(
|
Chris@16
|
292 connect_op<Protocol, SocketService, Iterator,
|
Chris@16
|
293 ConnectCondition, ComposedConnectHandler>* this_handler)
|
Chris@16
|
294 {
|
Chris@16
|
295 return boost_asio_handler_cont_helpers::is_continuation(
|
Chris@16
|
296 this_handler->handler_);
|
Chris@16
|
297 }
|
Chris@16
|
298
|
Chris@16
|
299 template <typename Function, typename Protocol,
|
Chris@16
|
300 typename SocketService, typename Iterator,
|
Chris@16
|
301 typename ConnectCondition, typename ComposedConnectHandler>
|
Chris@16
|
302 inline void asio_handler_invoke(Function& function,
|
Chris@16
|
303 connect_op<Protocol, SocketService, Iterator,
|
Chris@16
|
304 ConnectCondition, ComposedConnectHandler>* this_handler)
|
Chris@16
|
305 {
|
Chris@16
|
306 boost_asio_handler_invoke_helpers::invoke(
|
Chris@16
|
307 function, this_handler->handler_);
|
Chris@16
|
308 }
|
Chris@16
|
309
|
Chris@16
|
310 template <typename Function, typename Protocol,
|
Chris@16
|
311 typename SocketService, typename Iterator,
|
Chris@16
|
312 typename ConnectCondition, typename ComposedConnectHandler>
|
Chris@16
|
313 inline void asio_handler_invoke(const Function& function,
|
Chris@16
|
314 connect_op<Protocol, SocketService, Iterator,
|
Chris@16
|
315 ConnectCondition, ComposedConnectHandler>* this_handler)
|
Chris@16
|
316 {
|
Chris@16
|
317 boost_asio_handler_invoke_helpers::invoke(
|
Chris@16
|
318 function, this_handler->handler_);
|
Chris@16
|
319 }
|
Chris@16
|
320 } // namespace detail
|
Chris@16
|
321
|
Chris@16
|
322 template <typename Protocol, typename SocketService,
|
Chris@16
|
323 typename Iterator, typename ComposedConnectHandler>
|
Chris@16
|
324 inline BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
|
Chris@16
|
325 void (boost::system::error_code, Iterator))
|
Chris@16
|
326 async_connect(basic_socket<Protocol, SocketService>& s,
|
Chris@16
|
327 Iterator begin, BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler)
|
Chris@16
|
328 {
|
Chris@16
|
329 // If you get an error on the following line it means that your handler does
|
Chris@16
|
330 // not meet the documented type requirements for a ComposedConnectHandler.
|
Chris@16
|
331 BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
|
Chris@16
|
332 ComposedConnectHandler, handler, Iterator) type_check;
|
Chris@16
|
333
|
Chris@16
|
334 detail::async_result_init<ComposedConnectHandler,
|
Chris@16
|
335 void (boost::system::error_code, Iterator)> init(
|
Chris@16
|
336 BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler));
|
Chris@16
|
337
|
Chris@16
|
338 detail::connect_op<Protocol, SocketService, Iterator,
|
Chris@16
|
339 detail::default_connect_condition, BOOST_ASIO_HANDLER_TYPE(
|
Chris@16
|
340 ComposedConnectHandler, void (boost::system::error_code, Iterator))>(s,
|
Chris@16
|
341 begin, Iterator(), detail::default_connect_condition(), init.handler)(
|
Chris@16
|
342 boost::system::error_code(), 1);
|
Chris@16
|
343
|
Chris@16
|
344 return init.result.get();
|
Chris@16
|
345 }
|
Chris@16
|
346
|
Chris@16
|
347 template <typename Protocol, typename SocketService,
|
Chris@16
|
348 typename Iterator, typename ComposedConnectHandler>
|
Chris@16
|
349 inline BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
|
Chris@16
|
350 void (boost::system::error_code, Iterator))
|
Chris@16
|
351 async_connect(basic_socket<Protocol, SocketService>& s,
|
Chris@16
|
352 Iterator begin, Iterator end,
|
Chris@16
|
353 BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler)
|
Chris@16
|
354 {
|
Chris@16
|
355 // If you get an error on the following line it means that your handler does
|
Chris@16
|
356 // not meet the documented type requirements for a ComposedConnectHandler.
|
Chris@16
|
357 BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
|
Chris@16
|
358 ComposedConnectHandler, handler, Iterator) type_check;
|
Chris@16
|
359
|
Chris@16
|
360 detail::async_result_init<ComposedConnectHandler,
|
Chris@16
|
361 void (boost::system::error_code, Iterator)> init(
|
Chris@16
|
362 BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler));
|
Chris@16
|
363
|
Chris@16
|
364 detail::connect_op<Protocol, SocketService, Iterator,
|
Chris@16
|
365 detail::default_connect_condition, BOOST_ASIO_HANDLER_TYPE(
|
Chris@16
|
366 ComposedConnectHandler, void (boost::system::error_code, Iterator))>(s,
|
Chris@16
|
367 begin, end, detail::default_connect_condition(), init.handler)(
|
Chris@16
|
368 boost::system::error_code(), 1);
|
Chris@16
|
369
|
Chris@16
|
370 return init.result.get();
|
Chris@16
|
371 }
|
Chris@16
|
372
|
Chris@16
|
373 template <typename Protocol, typename SocketService, typename Iterator,
|
Chris@16
|
374 typename ConnectCondition, typename ComposedConnectHandler>
|
Chris@16
|
375 inline BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
|
Chris@16
|
376 void (boost::system::error_code, Iterator))
|
Chris@16
|
377 async_connect(basic_socket<Protocol, SocketService>& s,
|
Chris@16
|
378 Iterator begin, ConnectCondition connect_condition,
|
Chris@16
|
379 BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler)
|
Chris@16
|
380 {
|
Chris@16
|
381 // If you get an error on the following line it means that your handler does
|
Chris@16
|
382 // not meet the documented type requirements for a ComposedConnectHandler.
|
Chris@16
|
383 BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
|
Chris@16
|
384 ComposedConnectHandler, handler, Iterator) type_check;
|
Chris@16
|
385
|
Chris@16
|
386 detail::async_result_init<ComposedConnectHandler,
|
Chris@16
|
387 void (boost::system::error_code, Iterator)> init(
|
Chris@16
|
388 BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler));
|
Chris@16
|
389
|
Chris@16
|
390 detail::connect_op<Protocol, SocketService, Iterator,
|
Chris@16
|
391 ConnectCondition, BOOST_ASIO_HANDLER_TYPE(
|
Chris@16
|
392 ComposedConnectHandler, void (boost::system::error_code, Iterator))>(s,
|
Chris@16
|
393 begin, Iterator(), connect_condition, init.handler)(
|
Chris@16
|
394 boost::system::error_code(), 1);
|
Chris@16
|
395
|
Chris@16
|
396 return init.result.get();
|
Chris@16
|
397 }
|
Chris@16
|
398
|
Chris@16
|
399 template <typename Protocol, typename SocketService, typename Iterator,
|
Chris@16
|
400 typename ConnectCondition, typename ComposedConnectHandler>
|
Chris@16
|
401 inline BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
|
Chris@16
|
402 void (boost::system::error_code, Iterator))
|
Chris@16
|
403 async_connect(basic_socket<Protocol, SocketService>& s,
|
Chris@16
|
404 Iterator begin, Iterator end, ConnectCondition connect_condition,
|
Chris@16
|
405 BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler)
|
Chris@16
|
406 {
|
Chris@16
|
407 // If you get an error on the following line it means that your handler does
|
Chris@16
|
408 // not meet the documented type requirements for a ComposedConnectHandler.
|
Chris@16
|
409 BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
|
Chris@16
|
410 ComposedConnectHandler, handler, Iterator) type_check;
|
Chris@16
|
411
|
Chris@16
|
412 detail::async_result_init<ComposedConnectHandler,
|
Chris@16
|
413 void (boost::system::error_code, Iterator)> init(
|
Chris@16
|
414 BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler));
|
Chris@16
|
415
|
Chris@16
|
416 detail::connect_op<Protocol, SocketService, Iterator,
|
Chris@16
|
417 ConnectCondition, BOOST_ASIO_HANDLER_TYPE(
|
Chris@16
|
418 ComposedConnectHandler, void (boost::system::error_code, Iterator))>(s,
|
Chris@16
|
419 begin, end, connect_condition, init.handler)(
|
Chris@16
|
420 boost::system::error_code(), 1);
|
Chris@16
|
421
|
Chris@16
|
422 return init.result.get();
|
Chris@16
|
423 }
|
Chris@16
|
424
|
Chris@16
|
425 } // namespace asio
|
Chris@16
|
426 } // namespace boost
|
Chris@16
|
427
|
Chris@16
|
428 #include <boost/asio/detail/pop_options.hpp>
|
Chris@16
|
429
|
Chris@16
|
430 #endif // BOOST_ASIO_IMPL_CONNECT_HPP
|