E-MailRelay

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

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

`#include <gmultiserver.h>`

Inheritance diagram for GNet::MultiServer:
[legend]
Collaboration diagram for GNet::MultiServer:
[legend]

## Classes
struct | ServerInfo
| A structure used in GNet::MultiServer::newPeer(). More...

## Public Types
using | AddressList = std::vector< Address >

## Public Member Functions
| MultiServer (EventState es_listener, const G::StringArray &listen_list, unsigned int port, const std::string &server_type, ServerPeer::Config server_peer_config, Server::Config 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 (EventStateUnbound, ServerPeerInfo &&, const ServerInfo &)
| Pseudo-private method used by the pimple class. More...
| MultiServer (const MultiServer &)=delete
| MultiServer (MultiServer &&)=delete
MultiServer & | operator= (const MultiServer &)=delete
MultiServer & | operator= (MultiServer &&)=delete

## Protected Member Functions
virtual std::unique_ptr< ServerPeer > | newPeer (EventStateUnbound, ServerPeerInfo &&, ServerInfo)=0
| A factory method which creates 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 std::string &group={}) 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 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 47 of file gmultiserver.h.

## Member Typedef Documentation

## ◆ AddressList

using GNet::MultiServer::AddressList = std::vector<Address>

Definition at line 52 of file gmultiserver.h.

## Constructor & Destructor Documentation

## ◆ MultiServer()

GNet::MultiServer::MultiServer | ( | EventState | es_listener,
|  | const G::StringArray & | listen_list,
|  | unsigned int | port,
|  | const std::string & | server_type,
|  | ServerPeer::Config | server_peer_config,
|  | Server::Config | server_config
| ) |  |

Constructor.

The server listens on inherited file descriptors formatted like "fd#3", specific local addresses (eg. "127.0.0.1") and addresses from named interfaces ("eth0").

Listens on "0.0.0.0" and "::" if the listen list is empty.

Throws if there are no addresses in the list and the GNet::Interfaces implementation is not active().

Definition at line 32 of file gmultiserver.cpp.

## ◆ ~MultiServer()

GNet::MultiServer::~MultiServer | ( |  | ) |
| override

Destructor.

Definition at line 83 of file gmultiserver.cpp.

## Member Function Documentation

## ◆ doNewPeer()

std::unique_ptr< GNet::ServerPeer > GNet::MultiServer::doNewPeer | ( | EventStateUnbound | esu,
|  | ServerPeerInfo && | pi,
|  | const ServerInfo & | si
| ) |  |

Pseudo-private method used by the pimple class.

Definition at line 202 of file gmultiserver.cpp.

## ◆ hasPeers()

bool GNet::MultiServer::hasPeers | ( |  | ) | const

Returns true if peers() is not empty.

Definition at line 208 of file gmultiserver.cpp.

## ◆ newPeer()

virtual std::unique_ptr< ServerPeer > GNet::MultiServer::newPeer | ( | EventStateUnbound | ,
|  | ServerPeerInfo && | ,
|  | ServerInfo |
| ) |  |
| protected pure virtual

A factory method which creates a ServerPeer-derived object.

See GNet::Server for the details.

## ◆ peers()

std::vector< std::weak_ptr< GNet::ServerPeer > > GNet::MultiServer::peers | ( |  | ) |

Returns the list of ServerPeer-derived objects.

The returned ServerPeer objects must not outlive this MultiServer.

Definition at line 220 of file gmultiserver.cpp.

## ◆ serverCleanup()

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

## ◆ serverReport()

void GNet::MultiServer::serverReport | ( | const std::string & | group = `{}` | ) | const
| protected

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

Definition at line 191 of file gmultiserver.cpp.

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

- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gnet/gmultiserver.h
- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gnet/gmultiserver.cpp