40 class ServerPeerTimer ;
41 class ServerPeerHandle ;
84 G_EXCEPTION( CannotBind ,
"cannot bind the listening port" ) ;
88 shared_ptr<StreamSocket> m_socket ;
94 static bool canBind(
const Address & listening_address ,
bool do_throw ) ;
112 std::pair<bool,Address>
address()
const ;
155 void operator=(
const Server & ) ;
156 void serverCleanupCore() ;
157 void collectGarbage() ;
161 typedef std::list<ServerPeerHandle> PeerList ;
162 unique_ptr<StreamSocket> m_socket ;
163 PeerList m_peer_list ;
176 typedef std::string::size_type size_type ;
182 bool send(
const std::string & data , std::string::size_type offset = 0U ) ;
189 bool send(
const std::vector<std::pair<const char *,size_t> > & data ) ;
194 void doDelete(
const std::string & = std::string() ) ;
197 std::string
logId()
const ;
200 virtual std::pair<bool,Address>
localAddress()
const override ;
204 virtual std::pair<bool,Address>
peerAddress()
const override ;
221 virtual void onException( std::exception & ) g__final override ;
234 virtual void onDelete(
const std::string & reason ) = 0 ;
265 shared_ptr<StreamSocket> m_socket ;
virtual ServerPeer * newPeer(PeerInfo)=0
A factory method which new()s a ServerPeer-derived object.
An abstract base class for the GNet::Server's connection to a remote client.
static bool canBind(const Address &listening_address, bool do_throw)
Checks that the specified address can be bound.
ServerPeer(Server::PeerInfo)
Constructor.
The GNet::Address class encapsulates a TCP/UDP transport address.
virtual void onSendComplete()=0
Called after flow-control has been released and all residual data sent.
Server * server()
Returns a pointer to the associated server object.
void set(ServerPeer *p)
Sets the pointer.
virtual void readEvent() override
Override from GNet::EventHandler.
A network server class which listens on a specific port and spins off ServerPeer objects for each inc...
virtual void writeEvent() override
Override from GNet::EventHandler.
A structure used in the implementation of GNet::Server.
A derivation of GNet::Socket for a stream socket.
bool send(const std::string &data, std::string::size_type offset=0U)
Sends data down the socket to the peer.
Server()
Default constructor. Initialise with init().
StreamSocket & socket()
Returns a reference to the client-server connection socket.
void doDelete(const std::string &=std::string())
Does "onDelete(); delete this".
virtual void onDelete(const std::string &reason)=0
Called just before destruction.
virtual ~Server()
Destructor.
A base class for classes that handle asynchronous events from the event loop.
void doDeleteThis(int)
Does delete this. Should only be used by the GNet::Server class.
virtual std::string peerCertificate() const override
Returns the peer's TLS certificate.
An interface which provides address information for a network connection.
void reset()
Resets the pointer.
virtual std::pair< bool, Address > peerAddress() const override
Returns the peer address.
virtual void onException(std::exception &) g__final override
Override from GNet::EventHandler.
ServerPeer * old()
Returns the pointer value before it was reset().
virtual void writeEvent() override
Override from GNet::EventHandler.
std::string logId() const
Returns an identification string for logging purposes.
A timer class template in which the timeout is delivered to the specified method. ...
void serverCleanup()
May be called from the derived class destructor in order to trigger early deletion of peer objects...
void sslAccept()
Waits for the peer to start a secure session.
void init(const Address &listening_address)
Initilisation after default construction.
to deliver data from a socket.
An interface for implementing a low-level TLS/SSL protocol layer on top of a connected non-blocking s...
virtual ~ServerPeer()
Destructor.
A structure used in GNet::Server::newPeer().
ServerPeerHandle()
Default constructor.
virtual void readEvent() override
Override from GNet::EventHandler.
std::pair< bool, Address > address() const
Returns the listening address.
virtual std::pair< bool, Address > localAddress() const override
Returns the local address.
ServerPeer * peer()
Returns the pointer.