packio
Public Types | Public Member Functions | List of all members
packio::server< Rpc, Acceptor, Dispatcher > Class Template Reference

The server class. More...

#include <packio/server.h>

Public Types

using rpc_type = Rpc
 The RPC protocol type.
 
using acceptor_type = Acceptor
 The acceptor type.
 
using protocol_type = typename Acceptor::protocol_type
 The protocol type.
 
using dispatcher_type = Dispatcher
 The dispatcher type.
 
using executor_type = typename acceptor_type::executor_type
 The executor type.
 
using socket_type = std::decay_t< decltype(std::declval< acceptor_type >().accept())>
 The connection socket type.
 

Public Member Functions

 server (acceptor_type acceptor, std::shared_ptr< dispatcher_type > dispatcher)
 The constructor. More...
 
 server (acceptor_type acceptor)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
acceptor_typeacceptor ()
 Get the underlying acceptor.
 
const acceptor_typeacceptor () const
 Get the underlying acceptor, const.
 
std::shared_ptr< dispatcher_typedispatcher ()
 Get the dispatcher.
 
std::shared_ptr< const dispatcher_typedispatcher () const
 Get the dispatcher, const.
 
executor_type get_executor ()
 Get the executor associated with the object.
 
template<typename ServeHandler PACKIO_DEFAULT_COMPLETION_TOKEN_TYPE>
auto async_serve (ServeHandler &&handler=typename net::default_completion_token< executor_type >::type())
 Accept one connection and initialize a session for it. More...
 
void async_serve_forever ()
 Accept connections and automatically start the associated sessions forever.
 

Detailed Description

template<typename Rpc, typename Acceptor, typename Dispatcher = dispatcher<Rpc>>
class packio::server< Rpc, Acceptor, Dispatcher >

The server class.

Template Parameters
RpcRPC protocol implementation
AcceptorAcceptor type to use for this server
DispatcherDispatcher used to store and dispatch procedures. See dispatcher

Constructor & Destructor Documentation

◆ server()

template<typename Rpc , typename Acceptor , typename Dispatcher = dispatcher<Rpc>>
packio::server< Rpc, Acceptor, Dispatcher >::server ( acceptor_type  acceptor,
std::shared_ptr< dispatcher_type dispatcher 
)
inline

The constructor.

Parameters
acceptorThe acceptor that the server will use
dispatcherA shared pointer to the dispatcher that the server will use

Member Function Documentation

◆ async_serve()

template<typename Rpc , typename Acceptor , typename Dispatcher = dispatcher<Rpc>>
template<typename ServeHandler PACKIO_DEFAULT_COMPLETION_TOKEN_TYPE>
auto packio::server< Rpc, Acceptor, Dispatcher >::async_serve ( ServeHandler &&  handler = typename net::default_completion_token< executor_type >::type())
inline

Accept one connection and initialize a session for it.

Parameters
handlerHandler called when a connection is accepted. The handler is responsible for calling server_session::start. Must satisfy the traits::ServeHandler trait

The documentation for this class was generated from the following file: