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

A server that listens on more than one interface 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

typedef std::vector< Address > AddressList
 
typedef Server::PeerInfo PeerInfo
 

Public Member Functions

 MultiServer (ExceptionHandler &, const AddressList &address_list)
 Constructor. More...
 
 MultiServer (ExceptionHandler &)
 Default constructor. Initialise with init().
 
void init (const AddressList &address_list)
 Initilisation after default construction. More...
 
virtual ~MultiServer ()
 Destructor.
 
std::pair< bool, Address > firstAddress () const
 Returns the first listening address. More...
 
virtual ServerPeer * newPeer (PeerInfo, ServerInfo)=0
 A factory method which new()s a ServerPeer-derived object. More...
 

Static Public Member Functions

static bool canBind (const AddressList &listening_address_list, bool do_throw)
 Checks that the specified addresses can be bound. More...
 
static AddressList addressList (const Address &)
 A trivial convenience fuction that returns the given address as a single-element list. More...
 
static AddressList addressList (const AddressList &, unsigned int port)
 Returns the given list of addresses with the port set correctly. More...
 
static AddressList addressList (const G::StringArray &, unsigned int port)
 A convenience function that returns a list of listening addresses given a list of listening interfaces and a port number. More...
 

Protected Member Functions

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 std::string &server_type) const
 Writes to the system log a summary of the underlying server objects and their addresses. More...
 

Detailed Description

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

Definition at line 94 of file gmultiserver.h.

Constructor & Destructor Documentation

GNet::MultiServer::MultiServer ( ExceptionHandler &  eh,
const AddressList &  address_list 
)

Constructor.

The server listens on on the specific (local) interfaces.

Precondition: ! address_list.empty()

Definition at line 29 of file gmultiserver.cpp.

Member Function Documentation

GNet::MultiServer::AddressList GNet::MultiServer::addressList ( const Address &  address)
static

A trivial convenience fuction that returns the given address as a single-element list.

Definition at line 73 of file gmultiserver.cpp.

GNet::MultiServer::AddressList GNet::MultiServer::addressList ( const AddressList &  list,
unsigned int  port 
)
static

Returns the given list of addresses with the port set correctly.

If the given list is empty then a single 'any' address is returned.

Definition at line 81 of file gmultiserver.cpp.

GNet::MultiServer::AddressList GNet::MultiServer::addressList ( const G::StringArray &  list,
unsigned int  port 
)
static

A convenience function that returns a list of listening addresses given a list of listening interfaces and a port number.

If the list of interfaces is empty then a single 'any' address is returned.

Definition at line 99 of file gmultiserver.cpp.

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

Checks that the specified addresses can be bound.

Throws CannotBind if an address cannot be bound and 'do_throw' is true.

Definition at line 63 of file gmultiserver.cpp.

std::pair< bool, GNet::Address > GNet::MultiServer::firstAddress ( ) const

Returns the first listening address.

The boolean value is false if none.

Definition at line 151 of file gmultiserver.cpp.

void GNet::MultiServer::init ( const AddressList &  address_list)

Initilisation after default construction.

Precondition: ! address_list.empty()

Definition at line 46 of file gmultiserver.cpp.

virtual ServerPeer* GNet::MultiServer::newPeer ( PeerInfo  ,
ServerInfo   
)
pure virtual

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

See Server for the details.

Implemented in GSmtp::AdminServer.

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 128 of file gmultiserver.cpp.

void GNet::MultiServer::serverReport ( const std::string &  server_type) const
protected

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

Definition at line 142 of file gmultiserver.cpp.


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