11 #ifndef ASIO_DETAIL_REACTIVE_SOCKET_RECV_OP_HPP 12 #define ASIO_DETAIL_REACTIVE_SOCKET_RECV_OP_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 19 #include "asio/detail/bind_handler.hpp" 20 #include "asio/detail/buffer_sequence_adapter.hpp" 21 #include "asio/detail/fenced_block.hpp" 22 #include "asio/detail/handler_alloc_helpers.hpp" 23 #include "asio/detail/handler_invoke_helpers.hpp" 24 #include "asio/detail/handler_work.hpp" 25 #include "asio/detail/memory.hpp" 26 #include "asio/detail/reactor_op.hpp" 27 #include "asio/detail/socket_ops.hpp" 29 #include "asio/detail/push_options.hpp" 34 template <
typename MutableBufferSequence>
39 socket_type socket, socket_ops::state_type state,
40 const MutableBufferSequence& buffers,
43 &reactive_socket_recv_op_base::do_perform, complete_func),
54 static_cast<reactive_socket_recv_op_base*>(base));
57 MutableBufferSequence> bufs_type;
60 if (bufs_type::is_single_buffer)
62 result = socket_ops::non_blocking_recv1(o->socket_,
63 bufs_type::first(o->buffers_).data(),
64 bufs_type::first(o->buffers_).size(), o->flags_,
65 (o->state_ & socket_ops::stream_oriented) != 0,
66 o->ec_, o->bytes_transferred_) ? done : not_done;
70 bufs_type bufs(o->buffers_);
71 result = socket_ops::non_blocking_recv(o->socket_,
72 bufs.buffers(), bufs.count(), o->flags_,
73 (o->state_ & socket_ops::stream_oriented) != 0,
74 o->ec_, o->bytes_transferred_) ? done : not_done;
78 if ((o->state_ & socket_ops::stream_oriented) != 0)
79 if (o->bytes_transferred_ == 0)
80 result = done_and_exhausted;
82 ASIO_HANDLER_REACTOR_OPERATION((*o,
"non_blocking_recv",
83 o->ec_, o->bytes_transferred_));
90 socket_ops::state_type state_;
91 MutableBufferSequence buffers_;
95 template <
typename MutableBufferSequence,
typename Handler,
typename IoExecutor>
103 socket_type socket, socket_ops::state_type state,
105 Handler& handler,
const IoExecutor& io_ex)
107 state, buffers, flags, &reactive_socket_recv_op::do_complete),
108 handler_(ASIO_MOVE_CAST(Handler)(handler)),
109 work_(handler_, io_ex)
113 static void do_complete(
void* owner, operation* base,
119 ptr p = { asio::detail::addressof(o->handler_), o, o };
121 ASIO_HANDLER_COMPLETION((*o));
135 handler(o->handler_, o->ec_, o->bytes_transferred_);
136 p.h = asio::detail::addressof(handler.handler_);
143 ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_));
144 w.complete(handler, handler.handler_);
145 ASIO_HANDLER_INVOCATION_END;
157 #include "asio/detail/pop_options.hpp" 159 #endif // ASIO_DETAIL_REACTIVE_SOCKET_RECV_OP_HPP int message_flags
Bitmask type for flags that can be passed to send and receive operations.
Definition: socket_base.hpp:53
Definition: buffer_sequence_adapter.hpp:103
Holds a buffer that can be modified.
Definition: buffer.hpp:92
Definition: null_fenced_block.hpp:25
Class to represent an error code value.
Definition: error_code.hpp:80
Definition: reactive_socket_recv_op.hpp:35
Definition: reactor_op.hpp:26
Definition: any_io_executor.hpp:28
Definition: bind_handler.hpp:144
Definition: reactive_socket_recv_op.hpp:96