11 #ifndef ASIO_DETAIL_WIN_IOCP_SOCKET_ACCEPT_OP_HPP 12 #define ASIO_DETAIL_WIN_IOCP_SOCKET_ACCEPT_OP_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 20 #if defined(ASIO_HAS_IOCP) 38 template <
typename Socket,
typename Protocol,
typename Handler>
39 class win_iocp_socket_accept_op :
public operation 44 win_iocp_socket_accept_op(win_iocp_socket_service_base& socket_service,
46 typename Protocol::endpoint* peer_endpoint,
48 :
operation(&win_iocp_socket_accept_op::do_complete),
49 socket_service_(socket_service),
53 peer_endpoint_(peer_endpoint),
54 enable_connection_aborted_(enable_connection_aborted),
59 socket_holder& new_socket()
66 return output_buffer_;
69 DWORD address_length()
81 win_iocp_socket_accept_op* o(static_cast<win_iocp_socket_accept_op*>(base));
82 ptr p = { asio::detail::addressof(o->handler_), o, o };
86 typename Protocol::endpoint peer_endpoint;
87 std::size_t addr_len = peer_endpoint.capacity();
88 socket_ops::complete_iocp_accept(o->socket_,
89 o->output_buffer(), o->address_length(),
90 peer_endpoint.data(), &addr_len,
91 o->new_socket_.get(), ec);
96 && !o->enable_connection_aborted_)
99 o->socket_service_.restart_accept_op(o->socket_,
100 o->new_socket_, o->protocol_.family(),
101 o->protocol_.type(), o->protocol_.protocol(),
102 o->output_buffer(), o->address_length(), o);
111 o->peer_.assign(o->protocol_,
112 typename Socket::native_handle_type(
113 o->new_socket_.get(), peer_endpoint), ec);
115 o->new_socket_.release();
119 if (o->peer_endpoint_)
120 *o->peer_endpoint_ = peer_endpoint;
131 detail::binder1<Handler, asio::error_code>
132 handler(o->handler_, ec);
133 p.h = asio::detail::addressof(handler.handler_);
147 win_iocp_socket_service_base& socket_service_;
149 socket_holder new_socket_;
152 typename Protocol::endpoint* peer_endpoint_;
154 bool enable_connection_aborted_;
163 #endif // defined(ASIO_HAS_IOCP) 165 #endif // ASIO_DETAIL_WIN_IOCP_SOCKET_ACCEPT_OP_HPP
#define ASIO_HANDLER_INVOCATION_END
socket_type socket(int af, int type, int protocol, asio::error_code &ec)
sockaddr_storage sockaddr_storage_type
asio::basic_streambuf< Allocator > & b
null_fenced_block fenced_block
class task_io_service io_service_impl
void invoke(Function &function, Context &context)
#define ASIO_HANDLER_INVOCATION_BEGIN(args)
Class to represent an error code value.
task_io_service_operation operation
#define ASIO_DEFINE_HANDLER_PTR(op)
#define ASIO_HANDLER_COMPLETION(args)
#define ASIO_MOVE_CAST(type)
A connection has been aborted.