socket_acceptor_service.hpp
Go to the documentation of this file.
00001 //
00002 // socket_acceptor_service.hpp
00003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
00004 //
00005 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
00006 //
00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00009 //
00010 
00011 #ifndef ASIO_SOCKET_ACCEPTOR_SERVICE_HPP
00012 #define ASIO_SOCKET_ACCEPTOR_SERVICE_HPP
00013 
00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00015 # pragma once
00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
00017 
00018 #include "asio/detail/push_options.hpp"
00019 
00020 #include "asio/basic_socket.hpp"
00021 #include "asio/error.hpp"
00022 #include "asio/io_service.hpp"
00023 #include "asio/detail/epoll_reactor.hpp"
00024 #include "asio/detail/kqueue_reactor.hpp"
00025 #include "asio/detail/select_reactor.hpp"
00026 #include "asio/detail/service_base.hpp"
00027 #include "asio/detail/reactive_socket_service.hpp"
00028 #include "asio/detail/win_iocp_socket_service.hpp"
00029 
00030 namespace asio {
00031 
00033 template <typename Protocol>
00034 class socket_acceptor_service
00035 #if defined(GENERATING_DOCUMENTATION)
00036   : public asio::io_service::service
00037 #else
00038   : public asio::detail::service_base<socket_acceptor_service<Protocol> >
00039 #endif
00040 {
00041 public:
00042 #if defined(GENERATING_DOCUMENTATION)
00043 
00044   static asio::io_service::id id;
00045 #endif
00046 
00048   typedef Protocol protocol_type;
00049 
00051   typedef typename protocol_type::endpoint endpoint_type;
00052 
00053 private:
00054   // The type of the platform-specific implementation.
00055 #if defined(ASIO_HAS_IOCP)
00056   typedef detail::win_iocp_socket_service<Protocol> service_impl_type;
00057 #elif defined(ASIO_HAS_EPOLL)
00058   typedef detail::reactive_socket_service<
00059       Protocol, detail::epoll_reactor<false> > service_impl_type;
00060 #elif defined(ASIO_HAS_KQUEUE)
00061   typedef detail::reactive_socket_service<
00062       Protocol, detail::kqueue_reactor<false> > service_impl_type;
00063 #elif defined(ASIO_HAS_DEV_POLL)
00064   typedef detail::reactive_socket_service<
00065       Protocol, detail::dev_poll_reactor<false> > service_impl_type;
00066 #else
00067   typedef detail::reactive_socket_service<
00068       Protocol, detail::select_reactor<false> > service_impl_type;
00069 #endif
00070 
00071 public:
00073 #if defined(GENERATING_DOCUMENTATION)
00074   typedef implementation_defined implementation_type;
00075 #else
00076   typedef typename service_impl_type::implementation_type implementation_type;
00077 #endif
00078 
00080 #if defined(GENERATING_DOCUMENTATION)
00081   typedef implementation_defined native_type;
00082 #else
00083   typedef typename service_impl_type::native_type native_type;
00084 #endif
00085 
00087   explicit socket_acceptor_service(asio::io_service& io_service)
00088     : asio::detail::service_base<
00089         socket_acceptor_service<Protocol> >(io_service),
00090       service_impl_(asio::use_service<service_impl_type>(io_service))
00091   {
00092   }
00093 
00095   void shutdown_service()
00096   {
00097   }
00098 
00100   void construct(implementation_type& impl)
00101   {
00102     service_impl_.construct(impl);
00103   }
00104 
00106   void destroy(implementation_type& impl)
00107   {
00108     service_impl_.destroy(impl);
00109   }
00110 
00112   asio::error_code open(implementation_type& impl,
00113       const protocol_type& protocol, asio::error_code& ec)
00114   {
00115     return service_impl_.open(impl, protocol, ec);
00116   }
00117 
00119   asio::error_code assign(implementation_type& impl,
00120       const protocol_type& protocol, const native_type& native_acceptor,
00121       asio::error_code& ec)
00122   {
00123     return service_impl_.assign(impl, protocol, native_acceptor, ec);
00124   }
00125 
00127   bool is_open(const implementation_type& impl) const
00128   {
00129     return service_impl_.is_open(impl);
00130   }
00131 
00133   asio::error_code cancel(implementation_type& impl,
00134       asio::error_code& ec)
00135   {
00136     return service_impl_.cancel(impl, ec);
00137   }
00138 
00140   asio::error_code bind(implementation_type& impl,
00141       const endpoint_type& endpoint, asio::error_code& ec)
00142   {
00143     return service_impl_.bind(impl, endpoint, ec);
00144   }
00145 
00148   asio::error_code listen(implementation_type& impl, int backlog,
00149       asio::error_code& ec)
00150   {
00151     return service_impl_.listen(impl, backlog, ec);
00152   }
00153 
00155   asio::error_code close(implementation_type& impl,
00156       asio::error_code& ec)
00157   {
00158     return service_impl_.close(impl, ec);
00159   }
00160 
00162   native_type native(implementation_type& impl)
00163   {
00164     return service_impl_.native(impl);
00165   }
00166 
00168   template <typename SettableSocketOption>
00169   asio::error_code set_option(implementation_type& impl,
00170       const SettableSocketOption& option, asio::error_code& ec)
00171   {
00172     return service_impl_.set_option(impl, option, ec);
00173   }
00174 
00176   template <typename GettableSocketOption>
00177   asio::error_code get_option(const implementation_type& impl,
00178       GettableSocketOption& option, asio::error_code& ec) const
00179   {
00180     return service_impl_.get_option(impl, option, ec);
00181   }
00182 
00184   template <typename IoControlCommand>
00185   asio::error_code io_control(implementation_type& impl,
00186       IoControlCommand& command, asio::error_code& ec)
00187   {
00188     return service_impl_.io_control(impl, command, ec);
00189   }
00190 
00192   endpoint_type local_endpoint(const implementation_type& impl,
00193       asio::error_code& ec) const
00194   {
00195     return service_impl_.local_endpoint(impl, ec);
00196   }
00197 
00199   template <typename SocketService>
00200   asio::error_code accept(implementation_type& impl,
00201       basic_socket<protocol_type, SocketService>& peer,
00202       endpoint_type* peer_endpoint, asio::error_code& ec)
00203   {
00204     return service_impl_.accept(impl, peer, peer_endpoint, ec);
00205   }
00206 
00208   template <typename SocketService, typename AcceptHandler>
00209   void async_accept(implementation_type& impl,
00210       basic_socket<protocol_type, SocketService>& peer,
00211       endpoint_type* peer_endpoint, AcceptHandler handler)
00212   {
00213     service_impl_.async_accept(impl, peer, peer_endpoint, handler);
00214   }
00215 
00216 private:
00217   // The service that provides the platform-specific implementation.
00218   service_impl_type& service_impl_;
00219 };
00220 
00221 } // namespace asio
00222 
00223 #include "asio/detail/pop_options.hpp"
00224 
00225 #endif // ASIO_SOCKET_ACCEPTOR_SERVICE_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Castor
Author(s): Carpe Noctem
autogenerated on Fri Nov 8 2013 11:05:39