A server that listens on more than one interface using a facade pattern to multiple Server instances. More...
#include <gmultiserver.h>
Public Types | |
typedef std::list< Address > | AddressList |
typedef Server::PeerInfo | PeerInfo |
Public Member Functions | |
MultiServer (const AddressList &address_list, bool use_connection_lookup) | |
Constructor. More... | |
MultiServer () | |
Default constructor. Initialise with init(). More... | |
void | init (const AddressList &address_list) |
Initilisation after default construction. More... | |
virtual | ~MultiServer () |
Destructor. More... | |
std::pair< bool, Address > | firstAddress () const |
Returns the first listening address. More... | |
virtual ServerPeer * | newPeer (PeerInfo)=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 addresses 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::Strings &, 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... | |
A server that listens on more than one interface using a facade pattern to multiple Server instances.
Definition at line 102 of file gmultiserver.h.
typedef std::list<Address> GNet::MultiServer::AddressList |
Definition at line 105 of file gmultiserver.h.
Definition at line 106 of file gmultiserver.h.
GNet::MultiServer::MultiServer | ( | const AddressList & | address_list, |
bool | use_connection_lookup | ||
) |
Constructor.
The server listens on on the specific (local) interfaces.
If use_connection_lookup is true then there may be extra information available in the Server::PeerInfo structures.
Precondition: ! address_list.empty()
Definition at line 83 of file gmultiserver.cpp.
References G_ASSERT.
GNet::MultiServer::MultiServer | ( | ) |
Default constructor. Initialise with init().
Definition at line 95 of file gmultiserver.cpp.
|
virtual |
Destructor.
Definition at line 116 of file gmultiserver.cpp.
|
static |
A trivial convenience fuction that returns the given addresses as a single-element list.
Definition at line 41 of file gmultiserver.cpp.
Referenced by Main::Admin::newServer().
|
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 48 of file gmultiserver.cpp.
|
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 63 of file gmultiserver.cpp.
|
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 31 of file gmultiserver.cpp.
References GNet::Server::canBind().
std::pair< bool, GNet::Address > GNet::MultiServer::firstAddress | ( | ) | const |
Returns the first listening address.
The boolean value is false if none.
Definition at line 144 of file gmultiserver.cpp.
References GNet::Address::invalidAddress().
void GNet::MultiServer::init | ( | const AddressList & | address_list | ) |
Initilisation after default construction.
Precondition: ! address_list.empty()
Definition at line 99 of file gmultiserver.cpp.
References G_ASSERT.
|
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.
|
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 121 of file gmultiserver.cpp.
|
protected |
Writes to the system log a summary of the underlying server objects and their addresses.
Definition at line 135 of file gmultiserver.cpp.
References GNet::Server::address(), and G_LOG_S.