diff options
Diffstat (limited to '3rdParty/Boost/src/boost/asio/basic_stream_socket.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/basic_stream_socket.hpp | 148 |
1 files changed, 114 insertions, 34 deletions
diff --git a/3rdParty/Boost/src/boost/asio/basic_stream_socket.hpp b/3rdParty/Boost/src/boost/asio/basic_stream_socket.hpp index 87bd035..010f0aa 100644 --- a/3rdParty/Boost/src/boost/asio/basic_stream_socket.hpp +++ b/3rdParty/Boost/src/boost/asio/basic_stream_socket.hpp @@ -2,7 +2,7 @@ // basic_stream_socket.hpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -18,6 +18,7 @@ #include <boost/asio/detail/config.hpp> #include <cstddef> #include <boost/asio/basic_socket.hpp> +#include <boost/asio/detail/handler_type_requirements.hpp> #include <boost/asio/detail/throw_error.hpp> #include <boost/asio/error.hpp> #include <boost/asio/stream_socket_service.hpp> @@ -45,8 +46,12 @@ class basic_stream_socket : public basic_socket<Protocol, StreamSocketService> { public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// socket. + typedef typename StreamSocketService::native_handle_type native_type; + /// The native representation of a socket. - typedef typename StreamSocketService::native_type native_type; + typedef typename StreamSocketService::native_handle_type native_handle_type; /// The protocol type. typedef Protocol protocol_type; @@ -122,12 +127,47 @@ public: * @throws boost::system::system_error Thrown on failure. */ basic_stream_socket(boost::asio::io_service& io_service, - const protocol_type& protocol, const native_type& native_socket) + const protocol_type& protocol, const native_handle_type& native_socket) : basic_socket<Protocol, StreamSocketService>( io_service, protocol, native_socket) { } +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_stream_socket from another. + /** + * This constructor moves a stream socket from one object to another. + * + * @param other The other basic_stream_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_stream_socket(io_service&) constructor. + */ + basic_stream_socket(basic_stream_socket&& other) + : basic_socket<Protocol, StreamSocketService>( + BOOST_ASIO_MOVE_CAST(basic_stream_socket)(other)) + { + } + + /// Move-assign a basic_stream_socket from another. + /** + * This assignment operator moves a stream socket from one object to another. + * + * @param other The other basic_stream_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_stream_socket(io_service&) constructor. + */ + basic_stream_socket& operator=(basic_stream_socket&& other) + { + basic_socket<Protocol, StreamSocketService>::operator=( + BOOST_ASIO_MOVE_CAST(basic_stream_socket)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Send some data on the socket. /** * This function is used to send data on the stream socket. The function @@ -157,9 +197,9 @@ public: std::size_t send(const ConstBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.send( - this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "send"); return s; } @@ -195,9 +235,9 @@ public: socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.send( - this->implementation, buffers, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "send"); return s; } @@ -223,7 +263,8 @@ public: std::size_t send(const ConstBufferSequence& buffers, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.send(this->implementation, buffers, flags, ec); + return this->get_service().send( + this->get_implementation(), buffers, flags, ec); } /// Start an asynchronous send. @@ -262,9 +303,15 @@ public: * std::vector. */ template <typename ConstBufferSequence, typename WriteHandler> - void async_send(const ConstBufferSequence& buffers, WriteHandler handler) + void async_send(const ConstBufferSequence& buffers, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), buffers, 0, + BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Start an asynchronous send. @@ -306,9 +353,15 @@ public: */ template <typename ConstBufferSequence, typename WriteHandler> void async_send(const ConstBufferSequence& buffers, - socket_base::message_flags flags, WriteHandler handler) + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send(this->implementation, buffers, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), buffers, flags, + BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Receive some data on the socket. @@ -343,8 +396,9 @@ public: std::size_t receive(const MutableBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.receive(this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "receive"); return s; } @@ -383,9 +437,9 @@ public: socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.receive( - this->implementation, buffers, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "receive"); return s; } @@ -411,7 +465,8 @@ public: std::size_t receive(const MutableBufferSequence& buffers, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.receive(this->implementation, buffers, flags, ec); + return this->get_service().receive( + this->get_implementation(), buffers, flags, ec); } /// Start an asynchronous receive. @@ -452,9 +507,15 @@ public: * std::vector. */ template <typename MutableBufferSequence, typename ReadHandler> - void async_receive(const MutableBufferSequence& buffers, ReadHandler handler) + void async_receive(const MutableBufferSequence& buffers, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), + buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Start an asynchronous receive. @@ -498,9 +559,15 @@ public: */ template <typename MutableBufferSequence, typename ReadHandler> void async_receive(const MutableBufferSequence& buffers, - socket_base::message_flags flags, ReadHandler handler) + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive(this->implementation, buffers, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), + buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Write some data to the socket. @@ -534,8 +601,9 @@ public: std::size_t write_some(const ConstBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.send(this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "write_some"); return s; } @@ -559,7 +627,7 @@ public: std::size_t write_some(const ConstBufferSequence& buffers, boost::system::error_code& ec) { - return this->service.send(this->implementation, buffers, 0, ec); + return this->get_service().send(this->get_implementation(), buffers, 0, ec); } /// Start an asynchronous write. @@ -599,9 +667,14 @@ public: */ template <typename ConstBufferSequence, typename WriteHandler> void async_write_some(const ConstBufferSequence& buffers, - WriteHandler handler) + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), + buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Read some data from the socket. @@ -636,8 +709,9 @@ public: std::size_t read_some(const MutableBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.receive(this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "read_some"); return s; } @@ -662,7 +736,8 @@ public: std::size_t read_some(const MutableBufferSequence& buffers, boost::system::error_code& ec) { - return this->service.receive(this->implementation, buffers, 0, ec); + return this->get_service().receive( + this->get_implementation(), buffers, 0, ec); } /// Start an asynchronous read. @@ -703,9 +778,14 @@ public: */ template <typename MutableBufferSequence, typename ReadHandler> void async_read_some(const MutableBufferSequence& buffers, - ReadHandler handler) + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), + buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } }; |