11 #ifndef ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP 12 #define ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 20 #if !defined(ASIO_HAS_IOCP) 46 template <
typename Protocol>
102 template <
typename Protocol1>
110 other_impl.
protocol_ =
typename Protocol1::endpoint().protocol();
117 if (!
do_open(impl, protocol.family(),
118 protocol.type(), protocol.protocol(), ec))
125 const protocol_type& protocol,
const native_handle_type& native_socket,
128 if (!
do_assign(impl, protocol.type(), native_socket, ec))
148 template <
typename Option>
159 template <
typename Option>
163 std::size_t size = option.size(impl.
protocol_);
176 endpoint_type endpoint;
177 std::size_t addr_len = endpoint.capacity();
180 endpoint.resize(addr_len);
188 endpoint_type endpoint;
189 std::size_t addr_len = endpoint.capacity();
191 endpoint.data(), &addr_len,
false, ec))
193 endpoint.resize(addr_len);
199 template <
typename ConstBufferSequence>
205 ConstBufferSequence> bufs(buffers);
208 bufs.buffers(), bufs.count(), flags,
209 destination.data(), destination.size(), ec);
225 template <
typename ConstBufferSequence,
typename Handler>
227 const ConstBufferSequence&
buffers,
237 typename op::ptr p = { asio::detail::addressof(handler),
239 sizeof(op), handler), 0 };
240 p.p =
new (p.v) op(impl.
socket_, buffers, destination, flags, handler);
244 start_op(impl, reactor::write_op, p.p, is_continuation,
true,
false);
249 template <
typename Handler>
258 typename op::ptr p = { asio::detail::addressof(handler),
260 sizeof(op), handler), 0 };
261 p.p =
new (p.v) op(handler);
264 &impl,
"async_send_to(null_buffers)"));
266 start_op(impl, reactor::write_op, p.p, is_continuation,
false,
false);
272 template <
typename MutableBufferSequence>
274 const MutableBufferSequence&
buffers,
279 MutableBufferSequence> bufs(buffers);
281 std::size_t addr_len = sender_endpoint.capacity();
284 flags, sender_endpoint.data(), &addr_len, ec);
287 sender_endpoint.resize(addr_len);
309 template <
typename MutableBufferSequence,
typename Handler>
311 const MutableBufferSequence&
buffers, endpoint_type& sender_endpoint,
320 typename op::ptr p = { asio::detail::addressof(handler),
322 sizeof(op), handler), 0 };
324 p.p =
new (p.v) op(impl.
socket_, protocol,
325 buffers, sender_endpoint, flags, handler);
328 &impl,
"async_receive_from"));
331 (flags & socket_base::message_out_of_band)
332 ? reactor::except_op : reactor::read_op,
333 p.p, is_continuation,
true,
false);
338 template <
typename Handler>
348 typename op::ptr p = { asio::detail::addressof(handler),
350 sizeof(op), handler), 0 };
351 p.p =
new (p.v) op(handler);
354 &impl,
"async_receive_from(null_buffers)"));
360 (flags & socket_base::message_out_of_band)
361 ? reactor::except_op : reactor::read_op,
362 p.p, is_continuation,
false,
false);
367 template <
typename Socket>
378 std::size_t addr_len = peer_endpoint ? peer_endpoint->capacity() : 0;
380 impl.
state_, peer_endpoint ? peer_endpoint->data() : 0,
381 peer_endpoint ? &addr_len : 0, ec));
387 peer_endpoint->resize(addr_len);
397 template <
typename Socket,
typename Handler>
399 endpoint_type* peer_endpoint, Handler& handler)
406 typename op::ptr p = { asio::detail::addressof(handler),
408 sizeof(op), handler), 0 };
423 peer_endpoint.data(), peer_endpoint.size(), ec);
428 template <
typename Handler>
430 const endpoint_type& peer_endpoint, Handler& handler)
437 typename op::ptr p = { asio::detail::addressof(handler),
439 sizeof(op), handler), 0 };
440 p.p =
new (p.v) op(impl.
socket_, handler);
445 peer_endpoint.data(), peer_endpoint.size());
455 #endif // !defined(ASIO_HAS_IOCP) 457 #endif // ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP
int message_flags
Bitmask type for flags that can be passed to send and receive operations.
asio::error_code assign(implementation_type &impl, const protocol_type &protocol, const native_handle_type &native_socket, asio::error_code &ec)
asio::error_code bind(implementation_type &impl, const endpoint_type &endpoint, asio::error_code &ec)
ASIO_DECL void start_op(base_implementation_type &impl, int op_type, reactor_op *op, bool is_continuation, bool is_non_blocking, bool noop)
asio::error_code connect(implementation_type &impl, const endpoint_type &peer_endpoint, asio::error_code &ec)
Provides core I/O functionality.
Holds a buffer that cannot be modified.
asio::error_code get_option(const implementation_type &impl, Option &option, asio::error_code &ec) const
int getsockopt(socket_type s, state_type state, int level, int optname, void *optval, size_t *optlen, asio::error_code &ec)
int getsockname(socket_type s, socket_addr_type *addr, std::size_t *addrlen, asio::error_code &ec)
void async_send_to(implementation_type &impl, const null_buffers &, const endpoint_type &, socket_base::message_flags, Handler &handler)
socket_ops::state_type state_
int poll_read(socket_type s, state_type state, asio::error_code &ec)
void async_send_to(implementation_type &impl, const ConstBufferSequence &buffers, const endpoint_type &destination, socket_base::message_flags flags, Handler &handler)
void async_connect(implementation_type &impl, const endpoint_type &peer_endpoint, Handler &handler)
size_t sync_sendto(socket_type s, state_type state, const buf *bufs, size_t count, int flags, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)
ASIO_DECL asio::error_code do_assign(base_implementation_type &impl, int type, const native_handle_type &native_socket, asio::error_code &ec)
size_t send_to(implementation_type &impl, const null_buffers &, const endpoint_type &, socket_base::message_flags, asio::error_code &ec)
ASIO_DECL void start_connect_op(base_implementation_type &impl, reactor_op *op, bool is_continuation, const socket_addr_type *addr, size_t addrlen)
size_t send_to(implementation_type &impl, const ConstBufferSequence &buffers, const endpoint_type &destination, socket_base::message_flags flags, asio::error_code &ec)
const MutableBufferSequence & buffers
void move_assign(implementation_type &impl, reactive_socket_service_base &other_service, implementation_type &other_impl)
ASIO_DECL void base_move_construct(base_implementation_type &impl, base_implementation_type &other_impl)
int setsockopt(socket_type s, state_type &state, int level, int optname, const void *optval, std::size_t optlen, asio::error_code &ec)
endpoint_type local_endpoint(const implementation_type &impl, asio::error_code &ec) const
ASIO_DECL asio::error_code do_open(base_implementation_type &impl, int af, int type, int protocol, asio::error_code &ec)
void async_accept(implementation_type &impl, Socket &peer, endpoint_type *peer_endpoint, Handler &handler)
asio::error_code set_option(implementation_type &impl, const Option &option, asio::error_code &ec)
socket_type native_handle_type
Holds a buffer that can be modified.
int poll_write(socket_type s, state_type state, asio::error_code &ec)
asio::error_code open(implementation_type &impl, const protocol_type &protocol, asio::error_code &ec)
int bind(socket_type s, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)
void async_receive_from(implementation_type &impl, const MutableBufferSequence &buffers, endpoint_type &sender_endpoint, socket_base::message_flags flags, Handler &handler)
bool is_continuation(Context &context)
void converting_move_construct(implementation_type &impl, typename reactive_socket_service< Protocol1 >::implementation_type &other_impl)
void move_construct(implementation_type &impl, implementation_type &other_impl)
Class to represent an error code value.
ASIO_DECL void base_move_assign(base_implementation_type &impl, reactive_socket_service_base &other_service, base_implementation_type &other_impl)
ASIO_DECL void start_accept_op(base_implementation_type &impl, reactor_op *op, bool is_continuation, bool peer_is_open)
void sync_connect(socket_type s, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)
reactive_socket_service(asio::io_service &io_service)
void * allocate(std::size_t s, Handler &h)
int getpeername(socket_type s, socket_addr_type *addr, std::size_t *addrlen, bool cached, asio::error_code &ec)
size_t sync_recvfrom(socket_type s, state_type state, buf *bufs, size_t count, int flags, socket_addr_type *addr, std::size_t *addrlen, asio::error_code &ec)
Protocol::endpoint endpoint_type
native_handle_type native_handle(implementation_type &impl)
size_t receive_from(implementation_type &impl, const null_buffers &, endpoint_type &sender_endpoint, socket_base::message_flags, asio::error_code &ec)
void async_receive_from(implementation_type &impl, const null_buffers &, endpoint_type &sender_endpoint, socket_base::message_flags flags, Handler &handler)
#define ASIO_HANDLER_CREATION(args)
socket_type sync_accept(socket_type s, state_type state, socket_addr_type *addr, std::size_t *addrlen, asio::error_code &ec)
endpoint_type remote_endpoint(const implementation_type &impl, asio::error_code &ec) const
asio::error_code accept(implementation_type &impl, Socket &peer, endpoint_type *peer_endpoint, asio::error_code &ec)
size_t receive_from(implementation_type &impl, const MutableBufferSequence &buffers, endpoint_type &sender_endpoint, socket_base::message_flags flags, asio::error_code &ec)