Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:41

0001 //
0002 // detail/null_socket_service.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_DETAIL_NULL_SOCKET_SERVICE_HPP
0012 #define BOOST_ASIO_DETAIL_NULL_SOCKET_SERVICE_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 
0020 #if defined(BOOST_ASIO_WINDOWS_RUNTIME)
0021 
0022 #include <boost/asio/buffer.hpp>
0023 #include <boost/asio/error.hpp>
0024 #include <boost/asio/execution_context.hpp>
0025 #include <boost/asio/post.hpp>
0026 #include <boost/asio/socket_base.hpp>
0027 #include <boost/asio/detail/bind_handler.hpp>
0028 
0029 #include <boost/asio/detail/push_options.hpp>
0030 
0031 namespace boost {
0032 namespace asio {
0033 namespace detail {
0034 
0035 template <typename Protocol>
0036 class null_socket_service :
0037   public execution_context_service_base<null_socket_service<Protocol>>
0038 {
0039 public:
0040   // The protocol type.
0041   typedef Protocol protocol_type;
0042 
0043   // The endpoint type.
0044   typedef typename Protocol::endpoint endpoint_type;
0045 
0046   // The native type of a socket.
0047   typedef int native_handle_type;
0048 
0049   // The implementation type of the socket.
0050   struct implementation_type
0051   {
0052   };
0053 
0054   // Constructor.
0055   null_socket_service(execution_context& context)
0056     : execution_context_service_base<null_socket_service<Protocol>>(context)
0057   {
0058   }
0059 
0060   // Destroy all user-defined handler objects owned by the service.
0061   void shutdown()
0062   {
0063   }
0064 
0065   // Construct a new socket implementation.
0066   void construct(implementation_type&)
0067   {
0068   }
0069 
0070   // Move-construct a new socket implementation.
0071   void move_construct(implementation_type&, implementation_type&)
0072   {
0073   }
0074 
0075   // Move-assign from another socket implementation.
0076   void move_assign(implementation_type&,
0077       null_socket_service&, implementation_type&)
0078   {
0079   }
0080 
0081   // Move-construct a new socket implementation from another protocol type.
0082   template <typename Protocol1>
0083   void converting_move_construct(implementation_type&,
0084       null_socket_service<Protocol1>&,
0085       typename null_socket_service<Protocol1>::implementation_type&)
0086   {
0087   }
0088 
0089   // Destroy a socket implementation.
0090   void destroy(implementation_type&)
0091   {
0092   }
0093 
0094   // Open a new socket implementation.
0095   boost::system::error_code open(implementation_type&,
0096       const protocol_type&, boost::system::error_code& ec)
0097   {
0098     ec = boost::asio::error::operation_not_supported;
0099     return ec;
0100   }
0101 
0102   // Assign a native socket to a socket implementation.
0103   boost::system::error_code assign(implementation_type&, const protocol_type&,
0104       const native_handle_type&, boost::system::error_code& ec)
0105   {
0106     ec = boost::asio::error::operation_not_supported;
0107     return ec;
0108   }
0109 
0110   // Determine whether the socket is open.
0111   bool is_open(const implementation_type&) const
0112   {
0113     return false;
0114   }
0115 
0116   // Destroy a socket implementation.
0117   boost::system::error_code close(implementation_type&,
0118       boost::system::error_code& ec)
0119   {
0120     ec = boost::asio::error::operation_not_supported;
0121     return ec;
0122   }
0123 
0124   // Release ownership of the socket.
0125   native_handle_type release(implementation_type&,
0126       boost::system::error_code& ec)
0127   {
0128     ec = boost::asio::error::operation_not_supported;
0129     return 0;
0130   }
0131 
0132   // Get the native socket representation.
0133   native_handle_type native_handle(implementation_type&)
0134   {
0135     return 0;
0136   }
0137 
0138   // Cancel all operations associated with the socket.
0139   boost::system::error_code cancel(implementation_type&,
0140       boost::system::error_code& ec)
0141   {
0142     ec = boost::asio::error::operation_not_supported;
0143     return ec;
0144   }
0145 
0146   // Determine whether the socket is at the out-of-band data mark.
0147   bool at_mark(const implementation_type&,
0148       boost::system::error_code& ec) const
0149   {
0150     ec = boost::asio::error::operation_not_supported;
0151     return false;
0152   }
0153 
0154   // Determine the number of bytes available for reading.
0155   std::size_t available(const implementation_type&,
0156       boost::system::error_code& ec) const
0157   {
0158     ec = boost::asio::error::operation_not_supported;
0159     return 0;
0160   }
0161 
0162   // Place the socket into the state where it will listen for new connections.
0163   boost::system::error_code listen(implementation_type&,
0164       int, boost::system::error_code& ec)
0165   {
0166     ec = boost::asio::error::operation_not_supported;
0167     return ec;
0168   }
0169 
0170   // Perform an IO control command on the socket.
0171   template <typename IO_Control_Command>
0172   boost::system::error_code io_control(implementation_type&,
0173       IO_Control_Command&, boost::system::error_code& ec)
0174   {
0175     ec = boost::asio::error::operation_not_supported;
0176     return ec;
0177   }
0178 
0179   // Gets the non-blocking mode of the socket.
0180   bool non_blocking(const implementation_type&) const
0181   {
0182     return false;
0183   }
0184 
0185   // Sets the non-blocking mode of the socket.
0186   boost::system::error_code non_blocking(implementation_type&,
0187       bool, boost::system::error_code& ec)
0188   {
0189     ec = boost::asio::error::operation_not_supported;
0190     return ec;
0191   }
0192 
0193   // Gets the non-blocking mode of the native socket implementation.
0194   bool native_non_blocking(const implementation_type&) const
0195   {
0196     return false;
0197   }
0198 
0199   // Sets the non-blocking mode of the native socket implementation.
0200   boost::system::error_code native_non_blocking(implementation_type&,
0201       bool, boost::system::error_code& ec)
0202   {
0203     ec = boost::asio::error::operation_not_supported;
0204     return ec;
0205   }
0206 
0207   // Disable sends or receives on the socket.
0208   boost::system::error_code shutdown(implementation_type&,
0209       socket_base::shutdown_type, boost::system::error_code& ec)
0210   {
0211     ec = boost::asio::error::operation_not_supported;
0212     return ec;
0213   }
0214 
0215   // Bind the socket to the specified local endpoint.
0216   boost::system::error_code bind(implementation_type&,
0217       const endpoint_type&, boost::system::error_code& ec)
0218   {
0219     ec = boost::asio::error::operation_not_supported;
0220     return ec;
0221   }
0222 
0223   // Set a socket option.
0224   template <typename Option>
0225   boost::system::error_code set_option(implementation_type&,
0226       const Option&, boost::system::error_code& ec)
0227   {
0228     ec = boost::asio::error::operation_not_supported;
0229     return ec;
0230   }
0231 
0232   // Set a socket option.
0233   template <typename Option>
0234   boost::system::error_code get_option(const implementation_type&,
0235       Option&, boost::system::error_code& ec) const
0236   {
0237     ec = boost::asio::error::operation_not_supported;
0238     return ec;
0239   }
0240 
0241   // Get the local endpoint.
0242   endpoint_type local_endpoint(const implementation_type&,
0243       boost::system::error_code& ec) const
0244   {
0245     ec = boost::asio::error::operation_not_supported;
0246     return endpoint_type();
0247   }
0248 
0249   // Get the remote endpoint.
0250   endpoint_type remote_endpoint(const implementation_type&,
0251       boost::system::error_code& ec) const
0252   {
0253     ec = boost::asio::error::operation_not_supported;
0254     return endpoint_type();
0255   }
0256 
0257   // Send the given data to the peer.
0258   template <typename ConstBufferSequence>
0259   std::size_t send(implementation_type&, const ConstBufferSequence&,
0260       socket_base::message_flags, boost::system::error_code& ec)
0261   {
0262     ec = boost::asio::error::operation_not_supported;
0263     return 0;
0264   }
0265 
0266   // Wait until data can be sent without blocking.
0267   std::size_t send(implementation_type&, const null_buffers&,
0268       socket_base::message_flags, boost::system::error_code& ec)
0269   {
0270     ec = boost::asio::error::operation_not_supported;
0271     return 0;
0272   }
0273 
0274   // Start an asynchronous send. The data being sent must be valid for the
0275   // lifetime of the asynchronous operation.
0276   template <typename ConstBufferSequence, typename Handler, typename IoExecutor>
0277   void async_send(implementation_type&, const ConstBufferSequence&,
0278       socket_base::message_flags, Handler& handler, const IoExecutor& io_ex)
0279   {
0280     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0281     const std::size_t bytes_transferred = 0;
0282     boost::asio::post(io_ex, detail::bind_handler(
0283           handler, ec, bytes_transferred));
0284   }
0285 
0286   // Start an asynchronous wait until data can be sent without blocking.
0287   template <typename Handler, typename IoExecutor>
0288   void async_send(implementation_type&, const null_buffers&,
0289       socket_base::message_flags, Handler& handler, const IoExecutor& io_ex)
0290   {
0291     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0292     const std::size_t bytes_transferred = 0;
0293     boost::asio::post(io_ex, detail::bind_handler(
0294           handler, ec, bytes_transferred));
0295   }
0296 
0297   // Receive some data from the peer. Returns the number of bytes received.
0298   template <typename MutableBufferSequence>
0299   std::size_t receive(implementation_type&, const MutableBufferSequence&,
0300       socket_base::message_flags, boost::system::error_code& ec)
0301   {
0302     ec = boost::asio::error::operation_not_supported;
0303     return 0;
0304   }
0305 
0306   // Wait until data can be received without blocking.
0307   std::size_t receive(implementation_type&, const null_buffers&,
0308       socket_base::message_flags, boost::system::error_code& ec)
0309   {
0310     ec = boost::asio::error::operation_not_supported;
0311     return 0;
0312   }
0313 
0314   // Start an asynchronous receive. The buffer for the data being received
0315   // must be valid for the lifetime of the asynchronous operation.
0316   template <typename MutableBufferSequence,
0317       typename Handler, typename IoExecutor>
0318   void async_receive(implementation_type&, const MutableBufferSequence&,
0319       socket_base::message_flags, Handler& handler, const IoExecutor& io_ex)
0320   {
0321     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0322     const std::size_t bytes_transferred = 0;
0323     boost::asio::post(io_ex, detail::bind_handler(
0324           handler, ec, bytes_transferred));
0325   }
0326 
0327   // Wait until data can be received without blocking.
0328   template <typename Handler, typename IoExecutor>
0329   void async_receive(implementation_type&, const null_buffers&,
0330       socket_base::message_flags, Handler& handler, const IoExecutor& io_ex)
0331   {
0332     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0333     const std::size_t bytes_transferred = 0;
0334     boost::asio::post(io_ex, detail::bind_handler(
0335           handler, ec, bytes_transferred));
0336   }
0337 
0338   // Receive some data with associated flags. Returns the number of bytes
0339   // received.
0340   template <typename MutableBufferSequence>
0341   std::size_t receive_with_flags(implementation_type&,
0342       const MutableBufferSequence&, socket_base::message_flags,
0343       socket_base::message_flags&, boost::system::error_code& ec)
0344   {
0345     ec = boost::asio::error::operation_not_supported;
0346     return 0;
0347   }
0348 
0349   // Wait until data can be received without blocking.
0350   std::size_t receive_with_flags(implementation_type&,
0351       const null_buffers&, socket_base::message_flags,
0352       socket_base::message_flags&, boost::system::error_code& ec)
0353   {
0354     ec = boost::asio::error::operation_not_supported;
0355     return 0;
0356   }
0357 
0358   // Start an asynchronous receive. The buffer for the data being received
0359   // must be valid for the lifetime of the asynchronous operation.
0360   template <typename MutableBufferSequence,
0361       typename Handler, typename IoExecutor>
0362   void async_receive_with_flags(implementation_type&,
0363       const MutableBufferSequence&, socket_base::message_flags,
0364       socket_base::message_flags&, Handler& handler, const IoExecutor& io_ex)
0365   {
0366     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0367     const std::size_t bytes_transferred = 0;
0368     boost::asio::post(io_ex, detail::bind_handler(
0369           handler, ec, bytes_transferred));
0370   }
0371 
0372   // Wait until data can be received without blocking.
0373   template <typename Handler, typename IoExecutor>
0374   void async_receive_with_flags(implementation_type&, const null_buffers&,
0375       socket_base::message_flags, socket_base::message_flags&,
0376       Handler& handler, const IoExecutor& io_ex)
0377   {
0378     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0379     const std::size_t bytes_transferred = 0;
0380     boost::asio::post(io_ex, detail::bind_handler(
0381           handler, ec, bytes_transferred));
0382   }
0383 
0384   // Send a datagram to the specified endpoint. Returns the number of bytes
0385   // sent.
0386   template <typename ConstBufferSequence>
0387   std::size_t send_to(implementation_type&, const ConstBufferSequence&,
0388       const endpoint_type&, socket_base::message_flags,
0389       boost::system::error_code& ec)
0390   {
0391     ec = boost::asio::error::operation_not_supported;
0392     return 0;
0393   }
0394 
0395   // Wait until data can be sent without blocking.
0396   std::size_t send_to(implementation_type&, const null_buffers&,
0397       const endpoint_type&, socket_base::message_flags,
0398       boost::system::error_code& ec)
0399   {
0400     ec = boost::asio::error::operation_not_supported;
0401     return 0;
0402   }
0403 
0404   // Start an asynchronous send. The data being sent must be valid for the
0405   // lifetime of the asynchronous operation.
0406   template <typename ConstBufferSequence, typename Handler, typename IoExecutor>
0407   void async_send_to(implementation_type&, const ConstBufferSequence&,
0408       const endpoint_type&, socket_base::message_flags,
0409       Handler& handler)
0410   {
0411     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0412     const std::size_t bytes_transferred = 0;
0413     boost::asio::post(io_ex, detail::bind_handler(
0414           handler, ec, bytes_transferred));
0415   }
0416 
0417   // Start an asynchronous wait until data can be sent without blocking.
0418   template <typename Handler, typename IoExecutor>
0419   void async_send_to(implementation_type&, const null_buffers&,
0420       const endpoint_type&, socket_base::message_flags,
0421       Handler& handler, const IoExecutor& io_ex)
0422   {
0423     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0424     const std::size_t bytes_transferred = 0;
0425     boost::asio::post(io_ex, detail::bind_handler(
0426           handler, ec, bytes_transferred));
0427   }
0428 
0429   // Receive a datagram with the endpoint of the sender. Returns the number of
0430   // bytes received.
0431   template <typename MutableBufferSequence>
0432   std::size_t receive_from(implementation_type&, const MutableBufferSequence&,
0433       endpoint_type&, socket_base::message_flags,
0434       boost::system::error_code& ec)
0435   {
0436     ec = boost::asio::error::operation_not_supported;
0437     return 0;
0438   }
0439 
0440   // Wait until data can be received without blocking.
0441   std::size_t receive_from(implementation_type&, const null_buffers&,
0442       endpoint_type&, socket_base::message_flags,
0443       boost::system::error_code& ec)
0444   {
0445     ec = boost::asio::error::operation_not_supported;
0446     return 0;
0447   }
0448 
0449   // Start an asynchronous receive. The buffer for the data being received and
0450   // the sender_endpoint object must both be valid for the lifetime of the
0451   // asynchronous operation.
0452   template <typename MutableBufferSequence,
0453       typename Handler, typename IoExecutor>
0454   void async_receive_from(implementation_type&, const MutableBufferSequence&,
0455       endpoint_type&, socket_base::message_flags, Handler& handler,
0456       const IoExecutor& io_ex)
0457   {
0458     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0459     const std::size_t bytes_transferred = 0;
0460     boost::asio::post(io_ex, detail::bind_handler(
0461           handler, ec, bytes_transferred));
0462   }
0463 
0464   // Wait until data can be received without blocking.
0465   template <typename Handler, typename IoExecutor>
0466   void async_receive_from(implementation_type&, const null_buffers&,
0467       endpoint_type&, socket_base::message_flags, Handler& handler,
0468       const IoExecutor& io_ex)
0469   {
0470     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0471     const std::size_t bytes_transferred = 0;
0472     boost::asio::post(io_ex, detail::bind_handler(
0473           handler, ec, bytes_transferred));
0474   }
0475 
0476   // Accept a new connection.
0477   template <typename Socket>
0478   boost::system::error_code accept(implementation_type&,
0479       Socket&, endpoint_type*, boost::system::error_code& ec)
0480   {
0481     ec = boost::asio::error::operation_not_supported;
0482     return ec;
0483   }
0484 
0485   // Start an asynchronous accept. The peer and peer_endpoint objects
0486   // must be valid until the accept's handler is invoked.
0487   template <typename Socket, typename Handler, typename IoExecutor>
0488   void async_accept(implementation_type&, Socket&, endpoint_type*,
0489       Handler& handler, const IoExecutor& io_ex)
0490   {
0491     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0492     boost::asio::post(io_ex, detail::bind_handler(handler, ec));
0493   }
0494 
0495   // Connect the socket to the specified endpoint.
0496   boost::system::error_code connect(implementation_type&,
0497       const endpoint_type&, boost::system::error_code& ec)
0498   {
0499     ec = boost::asio::error::operation_not_supported;
0500     return ec;
0501   }
0502 
0503   // Start an asynchronous connect.
0504   template <typename Handler, typename IoExecutor>
0505   void async_connect(implementation_type&, const endpoint_type&,
0506       Handler& handler, const IoExecutor& io_ex)
0507   {
0508     boost::system::error_code ec = boost::asio::error::operation_not_supported;
0509     boost::asio::post(io_ex, detail::bind_handler(handler, ec));
0510   }
0511 };
0512 
0513 } // namespace detail
0514 } // namespace asio
0515 } // namespace boost
0516 
0517 #include <boost/asio/detail/pop_options.hpp>
0518 
0519 #endif // defined(BOOST_ASIO_WINDOWS_RUNTIME)
0520 
0521 #endif // BOOST_ASIO_DETAIL_NULL_SOCKET_SERVICE_HPP