GNet::MultiServer Class Reference

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

#include <gmultiserver.h>

Inheritance diagram for GNet::MultiServer:

GPop::Server GSmtp::AdminServer GSmtp::Server

List of all members.

Public Types

typedef std::list< AddressAddressList
typedef Server::PeerInfo PeerInfo

Public Member Functions

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

Static Public Member Functions

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

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


Detailed Description

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

Definition at line 101 of file gmultiserver.h.


Member Typedef Documentation

Reimplemented in GSmtp::Server.

Definition at line 104 of file gmultiserver.h.

Definition at line 105 of file gmultiserver.h.


Constructor & Destructor Documentation

GNet::MultiServer::MultiServer ( const AddressList address_list  )  [explicit]

Constructor.

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

Precondition: ! address_list.empty()

Definition at line 81 of file gmultiserver.cpp.

References G_ASSERT, and init().

GNet::MultiServer::MultiServer (  ) 

Default constructor. Initialise with init().

Definition at line 90 of file gmultiserver.cpp.

GNet::MultiServer::~MultiServer (  )  [virtual]

Destructor.

Definition at line 111 of file gmultiserver.cpp.

References serverCleanup().


Member Function Documentation

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

References GNet::Server::canBind().

GNet::MultiServer::AddressList GNet::MultiServer::addressList ( const Address address  )  [static]

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

Definition at line 39 of file gmultiserver.cpp.

References result.

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

References result.

GNet::MultiServer::AddressList GNet::MultiServer::addressList ( const G::Strings 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 61 of file gmultiserver.cpp.

References result.

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

Initilisation after default construction.

Precondition: ! address_list.empty()

Definition at line 94 of file gmultiserver.cpp.

References G_ASSERT.

Referenced by MultiServer().

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

Returns the first listening address.

The boolean value is false if none.

Definition at line 139 of file gmultiserver.cpp.

References GNet::Address::invalidAddress(), and result.

virtual ServerPeer* GNet::MultiServer::newPeer ( PeerInfo   )  [pure virtual]

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

See Server for the details.

Implemented in GSmtp::AdminServer, GSmtp::Server, and GPop::Server.

Referenced by GNet::MultiServerImp::newPeer().

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

Referenced by GSmtp::AdminServer::~AdminServer(), ~MultiServer(), GSmtp::Server::~Server(), and GPop::Server::~Server().

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

References GNet::Server::address(), and G_LOG_S.

Referenced by GSmtp::Server::report(), GPop::Server::report(), and GSmtp::AdminServer::report().


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

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5