- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

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 Server instances. More...

`#include <gmultiserver.h>`

Inheritance diagram for GNet::MultiServer:

## 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...

## Detailed Description

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.

## Member Typedef Documentation

typedef std::list<Address> GNet::MultiServer::AddressList

Definition at line 105 of file gmultiserver.h.

typedef Server::PeerInfo GNet::MultiServer::PeerInfo

Definition at line 106 of file gmultiserver.h.

## Constructor & Destructor Documentation

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.

GNet::MultiServer::~MultiServer | ( |  | ) |
| virtual

Destructor.

Definition at line 116 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 addresses as a single-element list.

Definition at line 41 of file gmultiserver.cpp.

Referenced by Main::Admin::newServer().

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

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 63 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 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.

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.

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

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

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

- gmultiserver.h
- gmultiserver.cpp