Chris@16: // Chris@16: // detail/null_socket_service.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_DETAIL_NULL_SOCKET_SERVICE_HPP Chris@16: #define BOOST_ASIO_DETAIL_NULL_SOCKET_SERVICE_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: Chris@16: #if defined(BOOST_ASIO_WINDOWS_RUNTIME) Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: namespace detail { Chris@16: Chris@16: template Chris@16: class null_socket_service Chris@16: { Chris@16: public: Chris@16: // The protocol type. Chris@16: typedef Protocol protocol_type; Chris@16: Chris@16: // The endpoint type. Chris@16: typedef typename Protocol::endpoint endpoint_type; Chris@16: Chris@16: // The native type of a socket. Chris@16: typedef int native_handle_type; Chris@16: Chris@16: // The implementation type of the socket. Chris@16: struct implementation_type Chris@16: { Chris@16: }; Chris@16: Chris@16: // Constructor. Chris@16: null_socket_service(boost::asio::io_service& io_service) Chris@16: : io_service_(io_service) Chris@16: { Chris@16: } Chris@16: Chris@16: // Destroy all user-defined handler objects owned by the service. Chris@16: void shutdown_service() Chris@16: { Chris@16: } Chris@16: Chris@16: // Construct a new socket implementation. Chris@16: void construct(implementation_type&) Chris@16: { Chris@16: } Chris@16: Chris@16: // Move-construct a new socket implementation. Chris@16: void move_construct(implementation_type&, implementation_type&) Chris@16: { Chris@16: } Chris@16: Chris@16: // Move-assign from another socket implementation. Chris@16: void move_assign(implementation_type&, Chris@16: null_socket_service&, implementation_type&) Chris@16: { Chris@16: } Chris@16: Chris@16: // Move-construct a new socket implementation from another protocol type. Chris@16: template Chris@16: void converting_move_construct(implementation_type&, Chris@16: typename null_socket_service::implementation_type&) Chris@16: { Chris@16: } Chris@16: Chris@16: // Destroy a socket implementation. Chris@16: void destroy(implementation_type&) Chris@16: { Chris@16: } Chris@16: Chris@16: // Open a new socket implementation. Chris@16: boost::system::error_code open(implementation_type&, Chris@16: const protocol_type&, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Assign a native socket to a socket implementation. Chris@16: boost::system::error_code assign(implementation_type&, const protocol_type&, Chris@16: const native_handle_type&, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Determine whether the socket is open. Chris@16: bool is_open(const implementation_type&) const Chris@16: { Chris@16: return false; Chris@16: } Chris@16: Chris@16: // Destroy a socket implementation. Chris@16: boost::system::error_code close(implementation_type&, Chris@16: boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Get the native socket representation. Chris@16: native_handle_type native_handle(implementation_type&) Chris@16: { Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Cancel all operations associated with the socket. Chris@16: boost::system::error_code cancel(implementation_type&, Chris@16: boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Determine whether the socket is at the out-of-band data mark. Chris@16: bool at_mark(const implementation_type&, Chris@16: boost::system::error_code& ec) const Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return false; Chris@16: } Chris@16: Chris@16: // Determine the number of bytes available for reading. Chris@16: std::size_t available(const implementation_type&, Chris@16: boost::system::error_code& ec) const Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Place the socket into the state where it will listen for new connections. Chris@16: boost::system::error_code listen(implementation_type&, Chris@16: int, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Perform an IO control command on the socket. Chris@16: template Chris@16: boost::system::error_code io_control(implementation_type&, Chris@16: IO_Control_Command&, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Gets the non-blocking mode of the socket. Chris@16: bool non_blocking(const implementation_type&) const Chris@16: { Chris@16: return false; Chris@16: } Chris@16: Chris@16: // Sets the non-blocking mode of the socket. Chris@16: boost::system::error_code non_blocking(implementation_type&, Chris@16: bool, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Gets the non-blocking mode of the native socket implementation. Chris@16: bool native_non_blocking(const implementation_type&) const Chris@16: { Chris@16: return false; Chris@16: } Chris@16: Chris@16: // Sets the non-blocking mode of the native socket implementation. Chris@16: boost::system::error_code native_non_blocking(implementation_type&, Chris@16: bool, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Disable sends or receives on the socket. Chris@16: boost::system::error_code shutdown(implementation_type&, Chris@16: socket_base::shutdown_type, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Bind the socket to the specified local endpoint. Chris@16: boost::system::error_code bind(implementation_type&, Chris@16: const endpoint_type&, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Set a socket option. Chris@16: template Chris@16: boost::system::error_code set_option(implementation_type&, Chris@16: const Option&, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Set a socket option. Chris@16: template Chris@16: boost::system::error_code get_option(const implementation_type&, Chris@16: Option&, boost::system::error_code& ec) const Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Get the local endpoint. Chris@16: endpoint_type local_endpoint(const implementation_type&, Chris@16: boost::system::error_code& ec) const Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return endpoint_type(); Chris@16: } Chris@16: Chris@16: // Get the remote endpoint. Chris@16: endpoint_type remote_endpoint(const implementation_type&, Chris@16: boost::system::error_code& ec) const Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return endpoint_type(); Chris@16: } Chris@16: Chris@16: // Send the given data to the peer. Chris@16: template Chris@16: std::size_t send(implementation_type&, const ConstBufferSequence&, Chris@16: socket_base::message_flags, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Wait until data can be sent without blocking. Chris@16: std::size_t send(implementation_type&, const null_buffers&, Chris@16: socket_base::message_flags, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Start an asynchronous send. The data being sent must be valid for the Chris@16: // lifetime of the asynchronous operation. Chris@16: template Chris@16: void async_send(implementation_type&, const ConstBufferSequence&, Chris@16: socket_base::message_flags, Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: const std::size_t bytes_transferred = 0; Chris@16: io_service_.post(detail::bind_handler(handler, ec, bytes_transferred)); Chris@16: } Chris@16: Chris@16: // Start an asynchronous wait until data can be sent without blocking. Chris@16: template Chris@16: void async_send(implementation_type&, const null_buffers&, Chris@16: socket_base::message_flags, Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: const std::size_t bytes_transferred = 0; Chris@16: io_service_.post(detail::bind_handler(handler, ec, bytes_transferred)); Chris@16: } Chris@16: Chris@16: // Receive some data from the peer. Returns the number of bytes received. Chris@16: template Chris@16: std::size_t receive(implementation_type&, const MutableBufferSequence&, Chris@16: socket_base::message_flags, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Wait until data can be received without blocking. Chris@16: std::size_t receive(implementation_type&, const null_buffers&, Chris@16: socket_base::message_flags, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Start an asynchronous receive. The buffer for the data being received Chris@16: // must be valid for the lifetime of the asynchronous operation. Chris@16: template Chris@16: void async_receive(implementation_type&, const MutableBufferSequence&, Chris@16: socket_base::message_flags, Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: const std::size_t bytes_transferred = 0; Chris@16: io_service_.post(detail::bind_handler(handler, ec, bytes_transferred)); Chris@16: } Chris@16: Chris@16: // Wait until data can be received without blocking. Chris@16: template Chris@16: void async_receive(implementation_type&, const null_buffers&, Chris@16: socket_base::message_flags, Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: const std::size_t bytes_transferred = 0; Chris@16: io_service_.post(detail::bind_handler(handler, ec, bytes_transferred)); Chris@16: } Chris@16: Chris@16: // Receive some data with associated flags. Returns the number of bytes Chris@16: // received. Chris@16: template Chris@16: std::size_t receive_with_flags(implementation_type&, Chris@16: const MutableBufferSequence&, socket_base::message_flags, Chris@16: socket_base::message_flags&, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Wait until data can be received without blocking. Chris@16: std::size_t receive_with_flags(implementation_type&, Chris@16: const null_buffers&, socket_base::message_flags, Chris@16: socket_base::message_flags&, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Start an asynchronous receive. The buffer for the data being received Chris@16: // must be valid for the lifetime of the asynchronous operation. Chris@16: template Chris@16: void async_receive_with_flags(implementation_type&, Chris@16: const MutableBufferSequence&, socket_base::message_flags, Chris@16: socket_base::message_flags&, Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: const std::size_t bytes_transferred = 0; Chris@16: io_service_.post(detail::bind_handler(handler, ec, bytes_transferred)); Chris@16: } Chris@16: Chris@16: // Wait until data can be received without blocking. Chris@16: template Chris@16: void async_receive_with_flags(implementation_type&, Chris@16: const null_buffers&, socket_base::message_flags, Chris@16: socket_base::message_flags&, Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: const std::size_t bytes_transferred = 0; Chris@16: io_service_.post(detail::bind_handler(handler, ec, bytes_transferred)); Chris@16: } Chris@16: Chris@16: // Send a datagram to the specified endpoint. Returns the number of bytes Chris@16: // sent. Chris@16: template Chris@16: std::size_t send_to(implementation_type&, const ConstBufferSequence&, Chris@16: const endpoint_type&, socket_base::message_flags, Chris@16: boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Wait until data can be sent without blocking. Chris@16: std::size_t send_to(implementation_type&, const null_buffers&, Chris@16: const endpoint_type&, socket_base::message_flags, Chris@16: boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Start an asynchronous send. The data being sent must be valid for the Chris@16: // lifetime of the asynchronous operation. Chris@16: template Chris@16: void async_send_to(implementation_type&, const ConstBufferSequence&, Chris@16: const endpoint_type&, socket_base::message_flags, Chris@16: Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: const std::size_t bytes_transferred = 0; Chris@16: io_service_.post(detail::bind_handler(handler, ec, bytes_transferred)); Chris@16: } Chris@16: Chris@16: // Start an asynchronous wait until data can be sent without blocking. Chris@16: template Chris@16: void async_send_to(implementation_type&, const null_buffers&, Chris@16: const endpoint_type&, socket_base::message_flags, Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: const std::size_t bytes_transferred = 0; Chris@16: io_service_.post(detail::bind_handler(handler, ec, bytes_transferred)); Chris@16: } Chris@16: Chris@16: // Receive a datagram with the endpoint of the sender. Returns the number of Chris@16: // bytes received. Chris@16: template Chris@16: std::size_t receive_from(implementation_type&, const MutableBufferSequence&, Chris@16: endpoint_type&, socket_base::message_flags, Chris@16: boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Wait until data can be received without blocking. Chris@16: std::size_t receive_from(implementation_type&, const null_buffers&, Chris@16: endpoint_type&, socket_base::message_flags, Chris@16: boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return 0; Chris@16: } Chris@16: Chris@16: // Start an asynchronous receive. The buffer for the data being received and Chris@16: // the sender_endpoint object must both be valid for the lifetime of the Chris@16: // asynchronous operation. Chris@16: template Chris@16: void async_receive_from(implementation_type&, Chris@16: const MutableBufferSequence&, endpoint_type&, Chris@16: socket_base::message_flags, Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: const std::size_t bytes_transferred = 0; Chris@16: io_service_.post(detail::bind_handler(handler, ec, bytes_transferred)); Chris@16: } Chris@16: Chris@16: // Wait until data can be received without blocking. Chris@16: template Chris@16: void async_receive_from(implementation_type&, Chris@16: const null_buffers&, endpoint_type&, Chris@16: socket_base::message_flags, Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: const std::size_t bytes_transferred = 0; Chris@16: io_service_.post(detail::bind_handler(handler, ec, bytes_transferred)); Chris@16: } Chris@16: Chris@16: // Accept a new connection. Chris@16: template Chris@16: boost::system::error_code accept(implementation_type&, Chris@16: Socket&, endpoint_type*, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Start an asynchronous accept. The peer and peer_endpoint objects Chris@16: // must be valid until the accept's handler is invoked. Chris@16: template Chris@16: void async_accept(implementation_type&, Socket&, Chris@16: endpoint_type*, Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: io_service_.post(detail::bind_handler(handler, ec)); Chris@16: } Chris@16: Chris@16: // Connect the socket to the specified endpoint. Chris@16: boost::system::error_code connect(implementation_type&, Chris@16: const endpoint_type&, boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::asio::error::operation_not_supported; Chris@16: return ec; Chris@16: } Chris@16: Chris@16: // Start an asynchronous connect. Chris@16: template Chris@16: void async_connect(implementation_type&, Chris@16: const endpoint_type&, Handler& handler) Chris@16: { Chris@16: boost::system::error_code ec = boost::asio::error::operation_not_supported; Chris@16: io_service_.post(detail::bind_handler(handler, ec)); Chris@16: } Chris@16: Chris@16: private: Chris@16: boost::asio::io_service& io_service_; Chris@16: }; Chris@16: Chris@16: } // namespace detail Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // defined(BOOST_ASIO_WINDOWS_RUNTIME) Chris@16: Chris@16: #endif // BOOST_ASIO_DETAIL_NULL_SOCKET_SERVICE_HPP