11 #ifndef ASIO_BASIC_STREAM_SOCKET_HPP 12 #define ASIO_BASIC_STREAM_SOCKET_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 20 #include "asio/async_result.hpp" 21 #include "asio/basic_socket.hpp" 22 #include "asio/detail/handler_type_requirements.hpp" 23 #include "asio/detail/non_const_lvalue.hpp" 24 #include "asio/detail/throw_error.hpp" 25 #include "asio/error.hpp" 27 #include "asio/detail/push_options.hpp" 31 #if !defined(ASIO_BASIC_STREAM_SOCKET_FWD_DECL) 32 #define ASIO_BASIC_STREAM_SOCKET_FWD_DECL 35 template <
typename Protocol,
typename Executor = any_io_executor>
38 #endif // !defined(ASIO_BASIC_STREAM_SOCKET_FWD_DECL) 52 template <
typename Protocol,
typename Executor>
61 template <
typename Executor1>
69 #if defined(GENERATING_DOCUMENTATION) 106 template <
typename ExecutionContext>
109 is_convertible<ExecutionContext&, execution_context&>::value
145 template <
typename ExecutionContext>
148 is_convertible<ExecutionContext&, execution_context&>::value
190 template <
typename ExecutionContext>
193 is_convertible<ExecutionContext&, execution_context&>::value
214 const protocol_type& protocol,
const native_handle_type& native_socket)
215 :
basic_socket<Protocol, Executor>(ex, protocol, native_socket)
234 template <
typename ExecutionContext>
236 const protocol_type& protocol,
const native_handle_type& native_socket,
238 is_convertible<ExecutionContext&, execution_context&>::value
240 :
basic_socket<Protocol, Executor>(context, protocol, native_socket)
244 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 290 template <
typename Protocol1,
typename Executor1>
293 is_convertible<Protocol1, Protocol>::value
294 && is_convertible<Executor1, Executor>::value
311 template <
typename Protocol1,
typename Executor1>
313 is_convertible<Protocol1, Protocol>::value
314 && is_convertible<Executor1, Executor>::value,
321 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 357 template <
typename ConstBufferSequence>
358 std::size_t
send(
const ConstBufferSequence& buffers)
361 std::size_t
s = this->impl_.get_service().send(
362 this->impl_.get_implementation(), buffers, 0, ec);
363 asio::detail::throw_error(ec,
"send");
394 template <
typename ConstBufferSequence>
395 std::size_t
send(
const ConstBufferSequence& buffers,
399 std::size_t
s = this->impl_.get_service().send(
400 this->impl_.get_implementation(), buffers, flags, ec);
401 asio::detail::throw_error(ec,
"send");
423 template <
typename ConstBufferSequence>
424 std::size_t
send(
const ConstBufferSequence& buffers,
427 return this->impl_.get_service().send(
428 this->impl_.get_implementation(), buffers, flags, ec);
466 template <
typename ConstBufferSequence,
468 std::size_t)) WriteHandler
469 ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
472 async_send(
const ConstBufferSequence& buffers,
473 ASIO_MOVE_ARG(WriteHandler) handler
474 ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
476 return async_initiate<WriteHandler,
478 initiate_async_send(
this), handler,
519 template <
typename ConstBufferSequence,
521 std::size_t)) WriteHandler
522 ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
525 async_send(
const ConstBufferSequence& buffers,
527 ASIO_MOVE_ARG(WriteHandler) handler
528 ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
530 return async_initiate<WriteHandler,
532 initiate_async_send(
this), handler, buffers, flags);
563 template <
typename MutableBufferSequence>
564 std::size_t
receive(
const MutableBufferSequence& buffers)
567 std::size_t
s = this->impl_.get_service().receive(
568 this->impl_.get_implementation(), buffers, 0, ec);
569 asio::detail::throw_error(ec,
"receive");
603 template <
typename MutableBufferSequence>
604 std::size_t
receive(
const MutableBufferSequence& buffers,
608 std::size_t
s = this->impl_.get_service().receive(
609 this->impl_.get_implementation(), buffers, flags, ec);
610 asio::detail::throw_error(ec,
"receive");
632 template <
typename MutableBufferSequence>
633 std::size_t
receive(
const MutableBufferSequence& buffers,
636 return this->impl_.get_service().receive(
637 this->impl_.get_implementation(), buffers, flags, ec);
677 template <
typename MutableBufferSequence,
679 std::size_t)) ReadHandler
680 ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
683 async_receive(
const MutableBufferSequence& buffers,
684 ASIO_MOVE_ARG(ReadHandler) handler
685 ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
687 return async_initiate<ReadHandler,
689 initiate_async_receive(
this), handler,
732 template <
typename MutableBufferSequence,
734 std::size_t)) ReadHandler
735 ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
738 async_receive(
const MutableBufferSequence& buffers,
740 ASIO_MOVE_ARG(ReadHandler) handler
741 ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
743 return async_initiate<ReadHandler,
745 initiate_async_receive(
this), handler, buffers, flags);
775 template <
typename ConstBufferSequence>
779 std::size_t
s = this->impl_.get_service().send(
780 this->impl_.get_implementation(), buffers, 0, ec);
781 asio::detail::throw_error(ec,
"write_some");
801 template <
typename ConstBufferSequence>
805 return this->impl_.get_service().send(
806 this->impl_.get_implementation(), buffers, 0, ec);
844 template <
typename ConstBufferSequence,
846 std::size_t)) WriteHandler
847 ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
850 async_write_some(
const ConstBufferSequence& buffers,
851 ASIO_MOVE_ARG(WriteHandler) handler
852 ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
854 return async_initiate<WriteHandler,
856 initiate_async_send(
this), handler,
888 template <
typename MutableBufferSequence>
889 std::size_t
read_some(
const MutableBufferSequence& buffers)
892 std::size_t
s = this->impl_.get_service().receive(
893 this->impl_.get_implementation(), buffers, 0, ec);
894 asio::detail::throw_error(ec,
"read_some");
915 template <
typename MutableBufferSequence>
916 std::size_t
read_some(
const MutableBufferSequence& buffers,
919 return this->impl_.get_service().receive(
920 this->impl_.get_implementation(), buffers, 0, ec);
959 template <
typename MutableBufferSequence,
961 std::size_t)) ReadHandler
962 ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
965 async_read_some(
const MutableBufferSequence& buffers,
966 ASIO_MOVE_ARG(ReadHandler) handler
967 ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
969 return async_initiate<ReadHandler,
971 initiate_async_receive(
this), handler,
980 class initiate_async_send
992 return self_->get_executor();
995 template <
typename WriteHandler,
typename ConstBufferSequence>
996 void operator()(ASIO_MOVE_ARG(WriteHandler) handler,
997 const ConstBufferSequence& buffers,
1002 ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
1005 self_->impl_.get_service().async_send(
1006 self_->impl_.get_implementation(), buffers, flags,
1007 handler2.value, self_->impl_.get_executor());
1014 class initiate_async_receive
1026 return self_->get_executor();
1029 template <
typename ReadHandler,
typename MutableBufferSequence>
1030 void operator()(ASIO_MOVE_ARG(ReadHandler) handler,
1031 const MutableBufferSequence& buffers,
1036 ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
1039 self_->impl_.get_service().async_receive(
1040 self_->impl_.get_implementation(), buffers, flags,
1041 handler2.value, self_->impl_.get_executor());
1051 #include "asio/detail/pop_options.hpp" 1053 #endif // ASIO_BASIC_STREAM_SOCKET_HPP int message_flags
Bitmask type for flags that can be passed to send and receive operations.
Definition: socket_base.hpp:53
std::size_t write_some(const ConstBufferSequence &buffers, asio::error_code &ec)
Write some data to the socket.
Definition: basic_stream_socket.hpp:802
std::size_t read_some(const MutableBufferSequence &buffers)
Read some data from the socket.
Definition: basic_stream_socket.hpp:889
basic_stream_socket(ExecutionContext &context, const endpoint_type &endpoint, typename enable_if< is_convertible< ExecutionContext &, execution_context &>::value >::type *=0)
Construct a basic_stream_socket, opening it and binding it to the given local endpoint.
Definition: basic_stream_socket.hpp:191
basic_socket< Protocol, Executor >::native_handle_type native_handle_type
The native representation of a socket.
Definition: basic_stream_socket.hpp:73
Definition: blocking.hpp:208
basic_stream_socket(const executor_type &ex, const protocol_type &protocol)
Construct and open a basic_stream_socket.
Definition: basic_stream_socket.hpp:127
ASIO_INITFN_AUTO_RESULT_TYPE(WriteHandler, void(asio::error_code, std::size_t)) async_send(const ConstBufferSequence &buffers
Start an asynchronous send.
Provides stream-oriented socket functionality.
Definition: basic_stream_socket.hpp:36
executor_type get_executor() ASIO_NOEXCEPT
Get the executor associated with the object.
Definition: basic_socket.hpp:366
basic_stream_socket(ExecutionContext &context, const protocol_type &protocol, typename enable_if< is_convertible< ExecutionContext &, execution_context &>::value >::type *=0)
Construct and open a basic_stream_socket.
Definition: basic_stream_socket.hpp:146
basic_stream_socket(const executor_type &ex, const protocol_type &protocol, const native_handle_type &native_socket)
Construct a basic_stream_socket on an existing native socket.
Definition: basic_stream_socket.hpp:213
basic_stream_socket(ExecutionContext &context, const protocol_type &protocol, const native_handle_type &native_socket, typename enable_if< is_convertible< ExecutionContext &, execution_context &>::value >::type *=0)
Construct a basic_stream_socket on an existing native socket.
Definition: basic_stream_socket.hpp:235
std::size_t send(const ConstBufferSequence &buffers, socket_base::message_flags flags, asio::error_code &ec)
Send some data on the socket.
Definition: basic_stream_socket.hpp:424
std::size_t receive(const MutableBufferSequence &buffers, socket_base::message_flags flags)
Receive some data on the socket.
Definition: basic_stream_socket.hpp:604
basic_stream_socket(ExecutionContext &context, typename enable_if< is_convertible< ExecutionContext &, execution_context &>::value >::type *=0)
Construct a basic_stream_socket without opening it.
Definition: basic_stream_socket.hpp:107
basic_stream_socket(const executor_type &ex, const endpoint_type &endpoint)
Construct a basic_stream_socket, opening it and binding it to the given local endpoint.
Definition: basic_stream_socket.hpp:169
Protocol::endpoint endpoint_type
The endpoint type.
Definition: basic_stream_socket.hpp:80
std::size_t receive(const MutableBufferSequence &buffers)
Receive some data on the socket.
Definition: basic_stream_socket.hpp:564
std::size_t send(const ConstBufferSequence &buffers)
Send some data on the socket.
Definition: basic_stream_socket.hpp:358
Definition: type_traits.hpp:97
Definition: non_const_lvalue.hpp:27
std::size_t write_some(const ConstBufferSequence &buffers)
Write some data to the socket.
Definition: basic_stream_socket.hpp:776
detail::reactive_socket_service< Protocol >::native_handle_type native_handle_type
The native representation of a socket.
Definition: basic_socket.hpp:92
Protocol protocol_type
The protocol type.
Definition: basic_stream_socket.hpp:77
Executor executor_type
The type of the executor associated with the object.
Definition: basic_stream_socket.hpp:58
std::size_t send(const ConstBufferSequence &buffers, socket_base::message_flags flags)
Send some data on the socket.
Definition: basic_stream_socket.hpp:395
Class to represent an error code value.
Definition: error_code.hpp:80
Rebinds the socket type to another executor.
Definition: basic_stream_socket.hpp:62
std::size_t read_some(const MutableBufferSequence &buffers, asio::error_code &ec)
Read some data from the socket.
Definition: basic_stream_socket.hpp:916
Provides socket functionality.
Definition: basic_socket.hpp:52
basic_stream_socket< Protocol, Executor1 > other
The socket type when rebound to the specified executor.
Definition: basic_stream_socket.hpp:65
basic_stream_socket(const executor_type &ex)
Construct a basic_stream_socket without opening it.
Definition: basic_stream_socket.hpp:91
~basic_stream_socket()
Destroys the socket.
Definition: basic_stream_socket.hpp:328
Definition: any_io_executor.hpp:28
std::size_t receive(const MutableBufferSequence &buffers, socket_base::message_flags flags, asio::error_code &ec)
Receive some data on a connected socket.
Definition: basic_stream_socket.hpp:633