42 class ServerPeerTimer ;
43 class ServerPeerHandle ;
86 G_EXCEPTION( CannotBind ,
"cannot bind the listening port" ) ;
88 G_EXCEPTION( AcceptError ,
"socket accept() failed" ) ;
100 static bool canBind(
const Address & listening_address ,
bool do_throw ) ;
116 void init(
unsigned int listening_port ) ;
125 std::pair<bool,Address>
address()
const ;
171 void operator=(
const Server & ) ;
172 void serverCleanupCore() ;
173 void collectGarbage() ;
177 typedef std::list<ServerPeerHandle> PeerList ;
178 std::auto_ptr<StreamSocket> m_socket ;
180 PeerList m_peer_list ;
205 void doDelete(
const std::string & = std::string() ) ;
208 std::string
logId()
const ;
215 virtual std::pair<bool,Address>
peerAddress()
const ;
241 virtual void onDelete(
const std::string & reason ) = 0 ;
272 std::auto_ptr<StreamSocket> m_socket ;
virtual void onException(std::exception &)
Final override from GNet::EventHandler.
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.
std::auto_ptr< StreamSocket > m_socket
static bool canBind(const Address &listening_address, bool do_throw)
Checks that the specified address can be bound.
virtual std::pair< bool, Address > localAddress() const
Returns the local address.
virtual std::pair< bool, Address > peerAddress() const
Returns the peer address.
virtual void writeEvent()
Final override from GNet::EventHandler.
ServerPeer(Server::PeerInfo)
Constructor.
The Address class encapsulates an IP transport address.
std::string::size_type size_type
A std::size_t type.
virtual void onSendComplete()=0
Called after flow-control has been released and all residual data sent.
ServerPeerHandle * m_handle
Server * server()
Returns a pointer to the associated server object.
void set(ServerPeer *p)
Sets the pointer.
A class for getting more information about a connection from the operating system.
A network server class which listens on a specific port and spins off ServerPeer objects for each inc...
A structure used in the implementation of GNet::Server.
A derivation of Socket for a stream socket.
virtual void readEvent()
Final override from GNet::EventHandler.
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 socket events.
void doDeleteThis(int)
Does delete this. Should only be used by the GNet::Server class.
virtual void readEvent()
Final override from GNet::EventHandler.
An interface which provides address information for a network connection.
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
virtual std::string peerCertificate() const
Returns the peer's TLS certificate.
void reset()
Resets the pointer.
virtual void writeEvent()
Final override from GNet::EventHandler.
ServerPeer * old()
Returns the pointer value before it was reset().
std::string logId() const
Returns an identification string for logging purposes.
void init(unsigned int listening_port)
Initilisation after default construction.
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.
An interface used by GNet::SocketProtocol to deliver data from a socket.
An interface for implementing a low-level protocol layer by means of calling read() and write() on a ...
virtual ~ServerPeer()
Destructor.
A structure used in GNet::Server::newPeer().
ServerPeerHandle()
Default constructor.
std::string::size_type size_type
std::pair< bool, Address > address() const
Returns the listening address.
ServerPeer * peer()
Returns the pointer.
virtual void onException(std::exception &e)
Final override from GNet::EventHandler.