win_iocp_socket_service.hpp 20 KB

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