11 #ifndef ASIO_DETAIL_WIN_IOCP_SOCKET_SERVICE_BASE_HPP 12 #define ASIO_DETAIL_WIN_IOCP_SOCKET_SERVICE_BASE_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 20 #if defined(ASIO_HAS_IOCP) 50 class win_iocp_socket_service_base
54 struct base_implementation_type
71 reactor::per_descriptor_data reactor_data_;
73 #if defined(ASIO_ENABLE_CANCELIO) 78 DWORD safe_cancellation_thread_id_;
79 #endif // defined(ASIO_ENABLE_CANCELIO) 82 base_implementation_type* next_;
83 base_implementation_type* prev_;
94 ASIO_DECL void construct(base_implementation_type& impl);
97 ASIO_DECL void base_move_construct(base_implementation_type& impl,
98 base_implementation_type& other_impl);
101 ASIO_DECL void base_move_assign(base_implementation_type& impl,
102 win_iocp_socket_service_base& other_service,
103 base_implementation_type& other_impl);
106 ASIO_DECL void destroy(base_implementation_type& impl);
109 bool is_open(
const base_implementation_type& impl)
const 123 bool at_mark(
const base_implementation_type& impl,
130 std::size_t
available(
const base_implementation_type& impl,
145 template <
typename IO_Control_Command>
155 bool non_blocking(
const base_implementation_type& impl)
const 169 bool native_non_blocking(
const base_implementation_type& impl)
const 191 template <
typename ConstBufferSequence>
192 size_t send(base_implementation_type& impl,
193 const ConstBufferSequence&
buffers,
197 ConstBufferSequence> bufs(buffers);
200 bufs.buffers(), bufs.count(), flags, bufs.all_empty(), ec);
204 size_t send(base_implementation_type& impl,
const null_buffers&,
215 template <
typename ConstBufferSequence,
typename Handler>
216 void async_send(base_implementation_type& impl,
217 const ConstBufferSequence& buffers,
221 typedef win_iocp_socket_send_op<ConstBufferSequence, Handler> op;
222 typename op::ptr p = { asio::detail::addressof(handler),
224 sizeof(op), handler), 0 };
225 p.p =
new (p.v) op(impl.cancel_token_, buffers, handler);
229 buffer_sequence_adapter<asio::const_buffer,
230 ConstBufferSequence> bufs(buffers);
232 start_send_op(impl, bufs.buffers(), bufs.count(), flags,
239 template <
typename Handler>
240 void async_send(base_implementation_type& impl,
const null_buffers&,
244 typedef win_iocp_null_buffers_op<Handler> op;
245 typename op::ptr p = { asio::detail::addressof(handler),
247 sizeof(op), handler), 0 };
248 p.p =
new (p.v) op(impl.cancel_token_, handler);
251 &impl,
"async_send(null_buffers)"));
253 start_reactor_op(impl, reactor::write_op, p.p);
258 template <
typename MutableBufferSequence>
259 size_t receive(base_implementation_type& impl,
260 const MutableBufferSequence& buffers,
264 MutableBufferSequence> bufs(buffers);
267 bufs.buffers(), bufs.count(), flags, bufs.all_empty(), ec);
271 size_t receive(base_implementation_type& impl,
const null_buffers&,
282 template <
typename MutableBufferSequence,
typename Handler>
283 void async_receive(base_implementation_type& impl,
284 const MutableBufferSequence& buffers,
288 typedef win_iocp_socket_recv_op<MutableBufferSequence, Handler> op;
289 typename op::ptr p = { asio::detail::addressof(handler),
291 sizeof(op), handler), 0 };
292 p.p =
new (p.v) op(impl.state_, impl.cancel_token_, buffers, handler);
296 buffer_sequence_adapter<asio::mutable_buffer,
297 MutableBufferSequence> bufs(buffers);
299 start_receive_op(impl, bufs.buffers(), bufs.count(), flags,
306 template <
typename Handler>
307 void async_receive(base_implementation_type& impl,
const null_buffers&,
311 typedef win_iocp_null_buffers_op<Handler> op;
312 typename op::ptr p = { asio::detail::addressof(handler),
314 sizeof(op), handler), 0 };
315 p.p =
new (p.v) op(impl.cancel_token_, handler);
318 &impl,
"async_receive(null_buffers)"));
320 start_null_buffers_receive_op(impl, flags, p.p);
326 template <
typename MutableBufferSequence>
327 size_t receive_with_flags(base_implementation_type& impl,
328 const MutableBufferSequence& buffers,
332 buffer_sequence_adapter<asio::mutable_buffer,
333 MutableBufferSequence> bufs(buffers);
336 bufs.buffers(), bufs.count(), in_flags, out_flags, ec);
340 size_t receive_with_flags(base_implementation_type& impl,
356 template <
typename MutableBufferSequence,
typename Handler>
357 void async_receive_with_flags(base_implementation_type& impl,
362 typedef win_iocp_socket_recvmsg_op<MutableBufferSequence, Handler> op;
363 typename op::ptr p = { asio::detail::addressof(handler),
365 sizeof(op), handler), 0 };
366 p.p =
new (p.v) op(impl.cancel_token_, buffers, out_flags, handler);
369 &impl,
"async_receive_with_flags"));
371 buffer_sequence_adapter<asio::mutable_buffer,
372 MutableBufferSequence> bufs(buffers);
374 start_receive_op(impl, bufs.buffers(), bufs.count(), in_flags,
false, p.p);
379 template <
typename Handler>
380 void async_receive_with_flags(base_implementation_type& impl,
385 typedef win_iocp_null_buffers_op<Handler> op;
386 typename op::ptr p = { asio::detail::addressof(handler),
388 sizeof(op), handler), 0 };
389 p.p =
new (p.v) op(impl.cancel_token_, handler);
392 "async_receive_with_flags(null_buffers)"));
397 start_null_buffers_receive_op(impl, in_flags, p.p);
403 socket_holder& new_socket,
int family,
int type,
int protocol,
404 void* output_buffer, DWORD address_length,
operation* op);
409 base_implementation_type& impl,
int family,
int type,
414 base_implementation_type& impl,
int type,
418 ASIO_DECL void start_send_op(base_implementation_type& impl,
419 WSABUF* buffers, std::size_t buffer_count,
423 ASIO_DECL void start_send_to_op(base_implementation_type& impl,
424 WSABUF* buffers, std::size_t buffer_count,
429 ASIO_DECL void start_receive_op(base_implementation_type& impl,
430 WSABUF* buffers, std::size_t buffer_count,
434 ASIO_DECL void start_null_buffers_receive_op(
435 base_implementation_type& impl,
439 ASIO_DECL void start_receive_from_op(base_implementation_type& impl,
444 ASIO_DECL void start_accept_op(base_implementation_type& impl,
445 bool peer_is_open, socket_holder& new_socket,
int family,
int type,
446 int protocol,
void* output_buffer, DWORD address_length,
operation* op);
449 ASIO_DECL void start_reactor_op(base_implementation_type& impl,
450 int op_type, reactor_op* op);
453 ASIO_DECL void start_connect_op(base_implementation_type& impl,
455 std::size_t remote_addrlen, win_iocp_socket_connect_op_base* op);
459 ASIO_DECL void close_for_destruction(base_implementation_type& impl);
462 ASIO_DECL void update_cancellation_thread_id(
463 base_implementation_type& impl);
471 typedef BOOL (PASCAL *connect_ex_fn)(SOCKET,
478 base_implementation_type& impl,
int type);
484 ASIO_DECL void* interlocked_compare_exchange_pointer(
485 void** dest,
void* exch,
void* cmp);
490 ASIO_DECL void* interlocked_exchange_pointer(
void** dest,
void* val);
497 win_iocp_io_service& iocp_service_;
510 base_implementation_type* impl_list_;
518 #if defined(ASIO_HEADER_ONLY) 520 #endif // defined(ASIO_HEADER_ONLY) 522 #endif // defined(ASIO_HAS_IOCP) 524 #endif // ASIO_DETAIL_WIN_IOCP_SOCKET_SERVICE_BASE_HPP int message_flags
Bitmask type for flags that can be passed to send and receive operations.
bool set_user_non_blocking(socket_type s, state_type &state, bool value, asio::error_code &ec)
shared_ptr< void > shared_cancel_token_type
Provides core I/O functionality.
size_t sync_recv(socket_type s, state_type state, buf *bufs, size_t count, int flags, bool all_empty, asio::error_code &ec)
Holds a buffer that cannot be modified.
bool sockatmark(socket_type s, asio::error_code &ec)
size_t sync_send(socket_type s, state_type state, const buf *bufs, size_t count, int flags, bool all_empty, asio::error_code &ec)
int poll_read(socket_type s, state_type state, asio::error_code &ec)
int listen(socket_type s, int backlog, asio::error_code &ec)
sockaddr socket_addr_type
const MutableBufferSequence & buffers
int ioctl(socket_type s, state_type &state, int cmd, ioctl_arg_type *arg, asio::error_code &ec)
signed_size_type send(socket_type s, const buf *bufs, size_t count, int flags, asio::error_code &ec)
Holds a buffer that can be modified.
class select_reactor reactor
int poll_write(socket_type s, state_type state, asio::error_code &ec)
shutdown_type
Different ways a socket may be shutdown.
size_t available(socket_type s, asio::error_code &ec)
Class to represent an error code value.
size_t sync_recvmsg(socket_type s, state_type state, buf *bufs, size_t count, int in_flags, int &out_flags, asio::error_code &ec)
task_io_service_operation operation
ASIO_DECL int close(int d, state_type &state, asio::error_code &ec)
void * allocate(std::size_t s, Handler &h)
int shutdown(socket_type s, int what, asio::error_code &ec)
#define ASIO_HANDLER_CREATION(args)
bool set_internal_non_blocking(socket_type s, state_type &state, bool value, asio::error_code &ec)