E-MailRelay
|
A server that listens on more than one address using a facade pattern to multiple GNet::Server instances. More...
#include <gmultiserver.h>
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< ServerPeer > | doNewPeer (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< ServerPeer > | newPeer (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 |
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.
using GNet::MultiServer::AddressList = std::vector<Address> |
Definition at line 47 of file gmultiserver.h.
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.
|
override |
Destructor.
Definition at line 81 of file gmultiserver.cpp.
|
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.
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.
bool GNet::MultiServer::hasPeers | ( | ) | const |
Returns true if peers() is not empty.
Definition at line 227 of file gmultiserver.cpp.
|
protectedpure virtual |
A factory method which new()s a ServerPeer-derived object.
See GNet::Server for the details.
Implemented in GSmtp::AdminServer.
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.
|
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.
|
protected |
Writes to the system log a summary of the underlying server objects and their addresses.
Definition at line 213 of file gmultiserver.cpp.
|
friend |
Definition at line 108 of file gmultiserver.h.