42 class ServerPeerConfig ;
43 class ServerPeerInfo ;
51 int listen_queue { G::limits::net_listen_queue } ;
52 bool uds_open_permissions {
true } ;
53 ServerConfig & set_uds_open_permissions(
bool b =
true ) ;
64 G_EXCEPTION( CannotBind ,
G::gettext_noop(
"cannot bind the listening port") ) ;
79 static bool canBind(
const Address & listening_address ,
bool do_throw ) ;
84 std::vector<std::weak_ptr<GNet::ServerPeer> >
peers() ;
116 void readEvent()
override ;
117 void writeEvent()
override ;
118 void onException(
ExceptionSource * , std::exception & ,
bool )
override ;
123 void operator=(
const Server & ) = delete ;
124 void operator=(
Server && ) = delete ;
128 static bool unlink(
G::SignalSafe ,
const char * ) noexcept ;
131 using PeerList = std::vector<std::shared_ptr<ServerPeer> > ;
135 PeerList m_peer_list ;
144 std::shared_ptr<StreamSocket> m_socket ;
151inline GNet::ServerConfig & GNet::ServerConfig::set_uds_open_permissions(
bool b ) { uds_open_permissions = b ;
return *this ; }
The GNet::Address class encapsulates a TCP/UDP transport address.
A base class for classes that handle asynchronous events from the event loop.
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket/future event...
A potential ExceptionSink that is realised by bind()ing an exception source pointer.
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
A mixin base class that identifies the source of an exception when delivered to GNet::ExceptionHandle...
An interface for a network listener.
A structure that GNet::Server uses to configure its ServerPeer objects.
A structure used in GNet::Server::newPeer().
A network server class which listens on a specific port and spins off ServerPeer objects for each inc...
~Server() override
Destructor.
Address address() const override
Returns the listening address.
bool hasPeers() const
Returns true if peers() is not empty.
virtual std::unique_ptr< ServerPeer > newPeer(ExceptionSinkUnbound, ServerPeerInfo)=0
A factory method which new()s a ServerPeer-derived object.
Server(ExceptionSink, const Address &listening_address, ServerPeerConfig, ServerConfig)
Constructor.
std::vector< std::weak_ptr< GNet::ServerPeer > > peers()
Returns the list of ServerPeer objects.
void serverCleanup()
Should be called by the most-derived class's destructor in order to trigger early deletion of peer ob...
static bool canBind(const Address &listening_address, bool do_throw)
Checks that the specified address can be bound.
A derivation of GNet::Socket for a stream socket.
An empty structure that is used to indicate a signal-safe, reentrant implementation.
constexpr const char * gettext_noop(const char *p)
Marks a string for translation at build-time, but no translation is applied at run-time.
A configuration structure for GNet::Server.