E-MailRelay
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
GNet::MultiServer Class Referenceabstract

A server that listens on more than one address using a facade pattern to multiple GNet::Server instances. More...

#include <gmultiserver.h>

+ Inheritance diagram for GNet::MultiServer:

Classes

struct  ServerInfo
 A structure used in GNet::MultiServer::newPeer(). More...
 

Public Types

using AddressList = std::vector< Address >
 

Public Member Functions

 MultiServer (ExceptionSink listener_exception_sink, const G::StringArray &addresses, unsigned int port, const std::string &server_type, ServerPeerConfig server_peer_config, ServerConfig server_config)
 Constructor. More...
 
 ~MultiServer () override
 Destructor. More...
 
bool hasPeers () const
 Returns true if peers() is not empty. More...
 
std::vector< std::weak_ptr< ServerPeer > > peers ()
 Returns the list of ServerPeer-derived objects. More...
 
std::unique_ptr< ServerPeerdoNewPeer (ExceptionSinkUnbound, const ServerPeerInfo &, const ServerInfo &)
 Pseudo-private method used by the pimple class. More...
 
 MultiServer (const MultiServer &)=delete
 
 MultiServer (MultiServer &&)=delete
 
void operator= (const MultiServer &)=delete
 
void operator= (MultiServer &&)=delete
 

Static Public Member Functions

static bool canBind (const AddressList &listening_address_list, bool do_throw)
 Checks that all the specified addresses can be bound. More...
 

Protected Member Functions

virtual std::unique_ptr< ServerPeernewPeer (ExceptionSinkUnbound, ServerPeerInfo, ServerInfo)=0
 A factory method which new()s a ServerPeer-derived object. More...
 
void serverCleanup ()
 Should be called from all derived classes' destructors so that peer objects can use their Server objects safely during their own destruction. More...
 
void serverReport () const
 Writes to the system log a summary of the underlying server objects and their addresses. More...
 

Friends

class GNet::MultiServerImp
 

Detailed Description

A server that listens on more than one address using a facade pattern to multiple GNet::Server instances.

Supports dynamic server instantiation based on available network interface addresses (see GNet::InterfacesHandler).

Definition at line 44 of file gmultiserver.h.

Member Typedef Documentation

◆ AddressList

using GNet::MultiServer::AddressList = std::vector<Address>

Definition at line 47 of file gmultiserver.h.

Constructor & Destructor Documentation

◆ MultiServer()

GNet::MultiServer::MultiServer ( ExceptionSink  listener_exception_sink,
const G::StringArray addresses,
unsigned int  port,
const std::string &  server_type,
ServerPeerConfig  server_peer_config,
ServerConfig  server_config 
)

Constructor.

The server listens on on the specific local addresses, given as either interface names (eg. "eth0") or IP network addresses (eg. "::1") together with a fixed port number. Throws if there are no addresses in the list and the GNet::Interfaces implementation is not active(). Listens on "0.0.0.0" and "::" if the list is empty.

Definition at line 31 of file gmultiserver.cpp.

◆ ~MultiServer()

GNet::MultiServer::~MultiServer ( )
override

Destructor.

Definition at line 81 of file gmultiserver.cpp.

Member Function Documentation

◆ canBind()

bool GNet::MultiServer::canBind ( const AddressList &  listening_address_list,
bool  do_throw 
)
static

Checks that all the specified addresses can be bound.

Throws CannotBind if any of those addresses cannot be bound and 'do_throw' is true.

Definition at line 202 of file gmultiserver.cpp.

◆ doNewPeer()

std::unique_ptr< GNet::ServerPeer > GNet::MultiServer::doNewPeer ( ExceptionSinkUnbound  esu,
const ServerPeerInfo pi,
const ServerInfo si 
)

Pseudo-private method used by the pimple class.

Definition at line 221 of file gmultiserver.cpp.

◆ hasPeers()

bool GNet::MultiServer::hasPeers ( ) const

Returns true if peers() is not empty.

Definition at line 227 of file gmultiserver.cpp.

◆ newPeer()

virtual std::unique_ptr< ServerPeer > GNet::MultiServer::newPeer ( ExceptionSinkUnbound  ,
ServerPeerInfo  ,
ServerInfo   
)
protectedpure virtual

A factory method which new()s a ServerPeer-derived object.

See GNet::Server for the details.

Implemented in GSmtp::AdminServer.

◆ peers()

std::vector< std::weak_ptr< GNet::ServerPeer > > GNet::MultiServer::peers ( )

Returns the list of ServerPeer-derived objects.

Definition at line 237 of file gmultiserver.cpp.

◆ serverCleanup()

void GNet::MultiServer::serverCleanup ( )
protected

Should be called from all derived classes' destructors so that peer objects can use their Server objects safely during their own destruction.

Definition at line 86 of file gmultiserver.cpp.

◆ serverReport()

void GNet::MultiServer::serverReport ( ) const
protected

Writes to the system log a summary of the underlying server objects and their addresses.

Definition at line 213 of file gmultiserver.cpp.

Friends And Related Function Documentation

◆ GNet::MultiServerImp

friend class GNet::MultiServerImp
friend

Definition at line 108 of file gmultiserver.h.


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