reactive_socket_service.hpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. //
  2. // detail/reactive_socket_service.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP
  11. #define ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #if !defined(ASIO_HAS_IOCP) \
  17. && !defined(ASIO_HAS_IO_URING_AS_DEFAULT)
  18. #include "asio/buffer.hpp"
  19. #include "asio/error.hpp"
  20. #include "asio/execution_context.hpp"
  21. #include "asio/socket_base.hpp"
  22. #include "asio/detail/buffer_sequence_adapter.hpp"
  23. #include "asio/detail/memory.hpp"
  24. #include "asio/detail/noncopyable.hpp"
  25. #include "asio/detail/reactive_null_buffers_op.hpp"
  26. #include "asio/detail/reactive_socket_accept_op.hpp"
  27. #include "asio/detail/reactive_socket_connect_op.hpp"
  28. #include "asio/detail/reactive_socket_recvfrom_op.hpp"
  29. #include "asio/detail/reactive_socket_sendto_op.hpp"
  30. #include "asio/detail/reactive_socket_service_base.hpp"
  31. #include "asio/detail/reactor.hpp"
  32. #include "asio/detail/reactor_op.hpp"
  33. #include "asio/detail/socket_holder.hpp"
  34. #include "asio/detail/socket_ops.hpp"
  35. #include "asio/detail/socket_types.hpp"
  36. #include "asio/detail/push_options.hpp"
  37. namespace asio {
  38. namespace detail {
  39. template <typename Protocol>
  40. class reactive_socket_service :
  41. public execution_context_service_base<reactive_socket_service<Protocol> >,
  42. public reactive_socket_service_base
  43. {
  44. public:
  45. // The protocol type.
  46. typedef Protocol protocol_type;
  47. // The endpoint type.
  48. typedef typename Protocol::endpoint endpoint_type;
  49. // The native type of a socket.
  50. typedef socket_type native_handle_type;
  51. // The implementation type of the socket.
  52. struct implementation_type :
  53. reactive_socket_service_base::base_implementation_type
  54. {
  55. // Default constructor.
  56. implementation_type()
  57. : protocol_(endpoint_type().protocol())
  58. {
  59. }
  60. // The protocol associated with the socket.
  61. protocol_type protocol_;
  62. };
  63. // Constructor.
  64. reactive_socket_service(execution_context& context)
  65. : execution_context_service_base<
  66. reactive_socket_service<Protocol> >(context),
  67. reactive_socket_service_base(context)
  68. {
  69. }
  70. // Destroy all user-defined handler objects owned by the service.
  71. void shutdown()
  72. {
  73. this->base_shutdown();
  74. }
  75. // Move-construct a new socket implementation.
  76. void move_construct(implementation_type& impl,
  77. implementation_type& other_impl) ASIO_NOEXCEPT
  78. {
  79. this->base_move_construct(impl, other_impl);
  80. impl.protocol_ = other_impl.protocol_;
  81. other_impl.protocol_ = endpoint_type().protocol();
  82. }
  83. // Move-assign from another socket implementation.
  84. void move_assign(implementation_type& impl,
  85. reactive_socket_service_base& other_service,
  86. implementation_type& other_impl)
  87. {
  88. this->base_move_assign(impl, other_service, other_impl);
  89. impl.protocol_ = other_impl.protocol_;
  90. other_impl.protocol_ = endpoint_type().protocol();
  91. }
  92. // Move-construct a new socket implementation from another protocol type.
  93. template <typename Protocol1>
  94. void converting_move_construct(implementation_type& impl,
  95. reactive_socket_service<Protocol1>&,
  96. typename reactive_socket_service<
  97. Protocol1>::implementation_type& other_impl)
  98. {
  99. this->base_move_construct(impl, other_impl);
  100. impl.protocol_ = protocol_type(other_impl.protocol_);
  101. other_impl.protocol_ = typename Protocol1::endpoint().protocol();
  102. }
  103. // Open a new socket implementation.
  104. asio::error_code open(implementation_type& impl,
  105. const protocol_type& protocol, asio::error_code& ec)
  106. {
  107. if (!do_open(impl, protocol.family(),
  108. protocol.type(), protocol.protocol(), ec))
  109. impl.protocol_ = protocol;
  110. return ec;
  111. }
  112. // Assign a native socket to a socket implementation.
  113. asio::error_code assign(implementation_type& impl,
  114. const protocol_type& protocol, const native_handle_type& native_socket,
  115. asio::error_code& ec)
  116. {
  117. if (!do_assign(impl, protocol.type(), native_socket, ec))
  118. impl.protocol_ = protocol;
  119. return ec;
  120. }
  121. // Get the native socket representation.
  122. native_handle_type native_handle(implementation_type& impl)
  123. {
  124. return impl.socket_;
  125. }
  126. // Bind the socket to the specified local endpoint.
  127. asio::error_code bind(implementation_type& impl,
  128. const endpoint_type& endpoint, asio::error_code& ec)
  129. {
  130. socket_ops::bind(impl.socket_, endpoint.data(), endpoint.size(), ec);
  131. return ec;
  132. }
  133. // Set a socket option.
  134. template <typename Option>
  135. asio::error_code set_option(implementation_type& impl,
  136. const Option& option, asio::error_code& ec)
  137. {
  138. socket_ops::setsockopt(impl.socket_, impl.state_,
  139. option.level(impl.protocol_), option.name(impl.protocol_),
  140. option.data(impl.protocol_), option.size(impl.protocol_), ec);
  141. return ec;
  142. }
  143. // Set a socket option.
  144. template <typename Option>
  145. asio::error_code get_option(const implementation_type& impl,
  146. Option& option, asio::error_code& ec) const
  147. {
  148. std::size_t size = option.size(impl.protocol_);
  149. socket_ops::getsockopt(impl.socket_, impl.state_,
  150. option.level(impl.protocol_), option.name(impl.protocol_),
  151. option.data(impl.protocol_), &size, ec);
  152. if (!ec)
  153. option.resize(impl.protocol_, size);
  154. return ec;
  155. }
  156. // Get the local endpoint.
  157. endpoint_type local_endpoint(const implementation_type& impl,
  158. asio::error_code& ec) const
  159. {
  160. endpoint_type endpoint;
  161. std::size_t addr_len = endpoint.capacity();
  162. if (socket_ops::getsockname(impl.socket_, endpoint.data(), &addr_len, ec))
  163. return endpoint_type();
  164. endpoint.resize(addr_len);
  165. return endpoint;
  166. }
  167. // Get the remote endpoint.
  168. endpoint_type remote_endpoint(const implementation_type& impl,
  169. asio::error_code& ec) const
  170. {
  171. endpoint_type endpoint;
  172. std::size_t addr_len = endpoint.capacity();
  173. if (socket_ops::getpeername(impl.socket_,
  174. endpoint.data(), &addr_len, false, ec))
  175. return endpoint_type();
  176. endpoint.resize(addr_len);
  177. return endpoint;
  178. }
  179. // Disable sends or receives on the socket.
  180. asio::error_code shutdown(base_implementation_type& impl,
  181. socket_base::shutdown_type what, asio::error_code& ec)
  182. {
  183. socket_ops::shutdown(impl.socket_, what, ec);
  184. return ec;
  185. }
  186. // Send a datagram to the specified endpoint. Returns the number of bytes
  187. // sent.
  188. template <typename ConstBufferSequence>
  189. size_t send_to(implementation_type& impl, const ConstBufferSequence& buffers,
  190. const endpoint_type& destination, socket_base::message_flags flags,
  191. asio::error_code& ec)
  192. {
  193. typedef buffer_sequence_adapter<asio::const_buffer,
  194. ConstBufferSequence> bufs_type;
  195. if (bufs_type::is_single_buffer)
  196. {
  197. return socket_ops::sync_sendto1(impl.socket_, impl.state_,
  198. bufs_type::first(buffers).data(),
  199. bufs_type::first(buffers).size(), flags,
  200. destination.data(), destination.size(), ec);
  201. }
  202. else
  203. {
  204. bufs_type bufs(buffers);
  205. return socket_ops::sync_sendto(impl.socket_, impl.state_,
  206. bufs.buffers(), bufs.count(), flags,
  207. destination.data(), destination.size(), ec);
  208. }
  209. }
  210. // Wait until data can be sent without blocking.
  211. size_t send_to(implementation_type& impl, const null_buffers&,
  212. const endpoint_type&, socket_base::message_flags,
  213. asio::error_code& ec)
  214. {
  215. // Wait for socket to become ready.
  216. socket_ops::poll_write(impl.socket_, impl.state_, -1, ec);
  217. return 0;
  218. }
  219. // Start an asynchronous send. The data being sent must be valid for the
  220. // lifetime of the asynchronous operation.
  221. template <typename ConstBufferSequence, typename Handler, typename IoExecutor>
  222. void async_send_to(implementation_type& impl,
  223. const ConstBufferSequence& buffers,
  224. const endpoint_type& destination, socket_base::message_flags flags,
  225. Handler& handler, const IoExecutor& io_ex)
  226. {
  227. bool is_continuation =
  228. asio_handler_cont_helpers::is_continuation(handler);
  229. typename associated_cancellation_slot<Handler>::type slot
  230. = asio::get_associated_cancellation_slot(handler);
  231. // Allocate and construct an operation to wrap the handler.
  232. typedef reactive_socket_sendto_op<ConstBufferSequence,
  233. endpoint_type, Handler, IoExecutor> op;
  234. typename op::ptr p = { asio::detail::addressof(handler),
  235. op::ptr::allocate(handler), 0 };
  236. p.p = new (p.v) op(success_ec_, impl.socket_,
  237. buffers, destination, flags, handler, io_ex);
  238. // Optionally register for per-operation cancellation.
  239. if (slot.is_connected())
  240. {
  241. p.p->cancellation_key_ =
  242. &slot.template emplace<reactor_op_cancellation>(
  243. &reactor_, &impl.reactor_data_, impl.socket_, reactor::write_op);
  244. }
  245. ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
  246. &impl, impl.socket_, "async_send_to"));
  247. start_op(impl, reactor::write_op, p.p, is_continuation, true, false);
  248. p.v = p.p = 0;
  249. }
  250. // Start an asynchronous wait until data can be sent without blocking.
  251. template <typename Handler, typename IoExecutor>
  252. void async_send_to(implementation_type& impl, const null_buffers&,
  253. const endpoint_type&, socket_base::message_flags,
  254. Handler& handler, const IoExecutor& io_ex)
  255. {
  256. bool is_continuation =
  257. asio_handler_cont_helpers::is_continuation(handler);
  258. typename associated_cancellation_slot<Handler>::type slot
  259. = asio::get_associated_cancellation_slot(handler);
  260. // Allocate and construct an operation to wrap the handler.
  261. typedef reactive_null_buffers_op<Handler, IoExecutor> op;
  262. typename op::ptr p = { asio::detail::addressof(handler),
  263. op::ptr::allocate(handler), 0 };
  264. p.p = new (p.v) op(success_ec_, handler, io_ex);
  265. // Optionally register for per-operation cancellation.
  266. if (slot.is_connected())
  267. {
  268. p.p->cancellation_key_ =
  269. &slot.template emplace<reactor_op_cancellation>(
  270. &reactor_, &impl.reactor_data_, impl.socket_, reactor::write_op);
  271. }
  272. ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
  273. &impl, impl.socket_, "async_send_to(null_buffers)"));
  274. start_op(impl, reactor::write_op, p.p, is_continuation, false, false);
  275. p.v = p.p = 0;
  276. }
  277. // Receive a datagram with the endpoint of the sender. Returns the number of
  278. // bytes received.
  279. template <typename MutableBufferSequence>
  280. size_t receive_from(implementation_type& impl,
  281. const MutableBufferSequence& buffers,
  282. endpoint_type& sender_endpoint, socket_base::message_flags flags,
  283. asio::error_code& ec)
  284. {
  285. typedef buffer_sequence_adapter<asio::mutable_buffer,
  286. MutableBufferSequence> bufs_type;
  287. std::size_t addr_len = sender_endpoint.capacity();
  288. std::size_t bytes_recvd;
  289. if (bufs_type::is_single_buffer)
  290. {
  291. bytes_recvd = socket_ops::sync_recvfrom1(impl.socket_,
  292. impl.state_, bufs_type::first(buffers).data(),
  293. bufs_type::first(buffers).size(), flags,
  294. sender_endpoint.data(), &addr_len, ec);
  295. }
  296. else
  297. {
  298. bufs_type bufs(buffers);
  299. bytes_recvd = socket_ops::sync_recvfrom(
  300. impl.socket_, impl.state_, bufs.buffers(), bufs.count(),
  301. flags, sender_endpoint.data(), &addr_len, ec);
  302. }
  303. if (!ec)
  304. sender_endpoint.resize(addr_len);
  305. return bytes_recvd;
  306. }
  307. // Wait until data can be received without blocking.
  308. size_t receive_from(implementation_type& impl, const null_buffers&,
  309. endpoint_type& sender_endpoint, socket_base::message_flags,
  310. asio::error_code& ec)
  311. {
  312. // Wait for socket to become ready.
  313. socket_ops::poll_read(impl.socket_, impl.state_, -1, ec);
  314. // Reset endpoint since it can be given no sensible value at this time.
  315. sender_endpoint = endpoint_type();
  316. return 0;
  317. }
  318. // Start an asynchronous receive. The buffer for the data being received and
  319. // the sender_endpoint object must both be valid for the lifetime of the
  320. // asynchronous operation.
  321. template <typename MutableBufferSequence,
  322. typename Handler, typename IoExecutor>
  323. void async_receive_from(implementation_type& impl,
  324. const MutableBufferSequence& buffers, endpoint_type& sender_endpoint,
  325. socket_base::message_flags flags, Handler& handler,
  326. const IoExecutor& io_ex)
  327. {
  328. bool is_continuation =
  329. asio_handler_cont_helpers::is_continuation(handler);
  330. typename associated_cancellation_slot<Handler>::type slot
  331. = asio::get_associated_cancellation_slot(handler);
  332. // Allocate and construct an operation to wrap the handler.
  333. typedef reactive_socket_recvfrom_op<MutableBufferSequence,
  334. endpoint_type, Handler, IoExecutor> op;
  335. typename op::ptr p = { asio::detail::addressof(handler),
  336. op::ptr::allocate(handler), 0 };
  337. int protocol = impl.protocol_.type();
  338. p.p = new (p.v) op(success_ec_, impl.socket_, protocol,
  339. buffers, sender_endpoint, flags, handler, io_ex);
  340. // Optionally register for per-operation cancellation.
  341. if (slot.is_connected())
  342. {
  343. p.p->cancellation_key_ =
  344. &slot.template emplace<reactor_op_cancellation>(
  345. &reactor_, &impl.reactor_data_, impl.socket_, reactor::read_op);
  346. }
  347. ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
  348. &impl, impl.socket_, "async_receive_from"));
  349. start_op(impl,
  350. (flags & socket_base::message_out_of_band)
  351. ? reactor::except_op : reactor::read_op,
  352. p.p, is_continuation, true, false);
  353. p.v = p.p = 0;
  354. }
  355. // Wait until data can be received without blocking.
  356. template <typename Handler, typename IoExecutor>
  357. void async_receive_from(implementation_type& impl, const null_buffers&,
  358. endpoint_type& sender_endpoint, socket_base::message_flags flags,
  359. Handler& handler, const IoExecutor& io_ex)
  360. {
  361. bool is_continuation =
  362. asio_handler_cont_helpers::is_continuation(handler);
  363. typename associated_cancellation_slot<Handler>::type slot
  364. = asio::get_associated_cancellation_slot(handler);
  365. // Allocate and construct an operation to wrap the handler.
  366. typedef reactive_null_buffers_op<Handler, IoExecutor> op;
  367. typename op::ptr p = { asio::detail::addressof(handler),
  368. op::ptr::allocate(handler), 0 };
  369. p.p = new (p.v) op(success_ec_, handler, io_ex);
  370. // Optionally register for per-operation cancellation.
  371. if (slot.is_connected())
  372. {
  373. p.p->cancellation_key_ =
  374. &slot.template emplace<reactor_op_cancellation>(
  375. &reactor_, &impl.reactor_data_, impl.socket_, reactor::read_op);
  376. }
  377. ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
  378. &impl, impl.socket_, "async_receive_from(null_buffers)"));
  379. // Reset endpoint since it can be given no sensible value at this time.
  380. sender_endpoint = endpoint_type();
  381. start_op(impl,
  382. (flags & socket_base::message_out_of_band)
  383. ? reactor::except_op : reactor::read_op,
  384. p.p, is_continuation, false, false);
  385. p.v = p.p = 0;
  386. }
  387. // Accept a new connection.
  388. template <typename Socket>
  389. asio::error_code accept(implementation_type& impl,
  390. Socket& peer, endpoint_type* peer_endpoint, asio::error_code& ec)
  391. {
  392. // We cannot accept a socket that is already open.
  393. if (peer.is_open())
  394. {
  395. ec = asio::error::already_open;
  396. return ec;
  397. }
  398. std::size_t addr_len = peer_endpoint ? peer_endpoint->capacity() : 0;
  399. socket_holder new_socket(socket_ops::sync_accept(impl.socket_,
  400. impl.state_, peer_endpoint ? peer_endpoint->data() : 0,
  401. peer_endpoint ? &addr_len : 0, ec));
  402. // On success, assign new connection to peer socket object.
  403. if (new_socket.get() != invalid_socket)
  404. {
  405. if (peer_endpoint)
  406. peer_endpoint->resize(addr_len);
  407. peer.assign(impl.protocol_, new_socket.get(), ec);
  408. if (!ec)
  409. new_socket.release();
  410. }
  411. return ec;
  412. }
  413. // Start an asynchronous accept. The peer and peer_endpoint objects must be
  414. // valid until the accept's handler is invoked.
  415. template <typename Socket, typename Handler, typename IoExecutor>
  416. void async_accept(implementation_type& impl, Socket& peer,
  417. endpoint_type* peer_endpoint, Handler& handler, const IoExecutor& io_ex)
  418. {
  419. bool is_continuation =
  420. asio_handler_cont_helpers::is_continuation(handler);
  421. typename associated_cancellation_slot<Handler>::type slot
  422. = asio::get_associated_cancellation_slot(handler);
  423. // Allocate and construct an operation to wrap the handler.
  424. typedef reactive_socket_accept_op<Socket, Protocol, Handler, IoExecutor> op;
  425. typename op::ptr p = { asio::detail::addressof(handler),
  426. op::ptr::allocate(handler), 0 };
  427. p.p = new (p.v) op(success_ec_, impl.socket_, impl.state_,
  428. peer, impl.protocol_, peer_endpoint, handler, io_ex);
  429. // Optionally register for per-operation cancellation.
  430. if (slot.is_connected() && !peer.is_open())
  431. {
  432. p.p->cancellation_key_ =
  433. &slot.template emplace<reactor_op_cancellation>(
  434. &reactor_, &impl.reactor_data_, impl.socket_, reactor::read_op);
  435. }
  436. ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
  437. &impl, impl.socket_, "async_accept"));
  438. start_accept_op(impl, p.p, is_continuation, peer.is_open());
  439. p.v = p.p = 0;
  440. }
  441. #if defined(ASIO_HAS_MOVE)
  442. // Start an asynchronous accept. The peer_endpoint object must be valid until
  443. // the accept's handler is invoked.
  444. template <typename PeerIoExecutor, typename Handler, typename IoExecutor>
  445. void async_move_accept(implementation_type& impl,
  446. const PeerIoExecutor& peer_io_ex, endpoint_type* peer_endpoint,
  447. Handler& handler, const IoExecutor& io_ex)
  448. {
  449. bool is_continuation =
  450. asio_handler_cont_helpers::is_continuation(handler);
  451. typename associated_cancellation_slot<Handler>::type slot
  452. = asio::get_associated_cancellation_slot(handler);
  453. // Allocate and construct an operation to wrap the handler.
  454. typedef reactive_socket_move_accept_op<Protocol,
  455. PeerIoExecutor, Handler, IoExecutor> op;
  456. typename op::ptr p = { asio::detail::addressof(handler),
  457. op::ptr::allocate(handler), 0 };
  458. p.p = new (p.v) op(success_ec_, peer_io_ex, impl.socket_,
  459. impl.state_, impl.protocol_, peer_endpoint, handler, io_ex);
  460. // Optionally register for per-operation cancellation.
  461. if (slot.is_connected())
  462. {
  463. p.p->cancellation_key_ =
  464. &slot.template emplace<reactor_op_cancellation>(
  465. &reactor_, &impl.reactor_data_, impl.socket_, reactor::read_op);
  466. }
  467. ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
  468. &impl, impl.socket_, "async_accept"));
  469. start_accept_op(impl, p.p, is_continuation, false);
  470. p.v = p.p = 0;
  471. }
  472. #endif // defined(ASIO_HAS_MOVE)
  473. // Connect the socket to the specified endpoint.
  474. asio::error_code connect(implementation_type& impl,
  475. const endpoint_type& peer_endpoint, asio::error_code& ec)
  476. {
  477. socket_ops::sync_connect(impl.socket_,
  478. peer_endpoint.data(), peer_endpoint.size(), ec);
  479. return ec;
  480. }
  481. // Start an asynchronous connect.
  482. template <typename Handler, typename IoExecutor>
  483. void async_connect(implementation_type& impl,
  484. const endpoint_type& peer_endpoint,
  485. Handler& handler, const IoExecutor& io_ex)
  486. {
  487. bool is_continuation =
  488. asio_handler_cont_helpers::is_continuation(handler);
  489. typename associated_cancellation_slot<Handler>::type slot
  490. = asio::get_associated_cancellation_slot(handler);
  491. // Allocate and construct an operation to wrap the handler.
  492. typedef reactive_socket_connect_op<Handler, IoExecutor> op;
  493. typename op::ptr p = { asio::detail::addressof(handler),
  494. op::ptr::allocate(handler), 0 };
  495. p.p = new (p.v) op(success_ec_, impl.socket_, handler, io_ex);
  496. // Optionally register for per-operation cancellation.
  497. if (slot.is_connected())
  498. {
  499. p.p->cancellation_key_ =
  500. &slot.template emplace<reactor_op_cancellation>(
  501. &reactor_, &impl.reactor_data_, impl.socket_, reactor::connect_op);
  502. }
  503. ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
  504. &impl, impl.socket_, "async_connect"));
  505. start_connect_op(impl, p.p, is_continuation,
  506. peer_endpoint.data(), peer_endpoint.size());
  507. p.v = p.p = 0;
  508. }
  509. };
  510. } // namespace detail
  511. } // namespace asio
  512. #include "asio/detail/pop_options.hpp"
  513. #endif // !defined(ASIO_HAS_IOCP)
  514. // && !defined(ASIO_HAS_IO_URING_AS_DEFAULT)
  515. #endif // ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP