#include <network.h>
Public Member Functions | |
NetworkServer (UInt16 port) | |
Constructor. Create server socket that listen on port. | |
virtual | ~NetworkServer () |
Destructor, close connections and destroy server socket. | |
void | run (void) |
Run and return only on SIGTERM. | |
void | step (bool block=false, long timeout=0) |
Read server and client sockets from incoming connection or datas and call incomingConnection or incomingData. If block is true, wait until any data arrives. If block is false, wait timeout us at maximum. | |
Protected Member Functions | |
virtual void | incomingData (Socket *socket)=0 |
Called when datas from client are available on socket. If socket is closed in this method, connectionClosed is called. Must be implemented by subclass. | |
virtual void | incomingConnection (Socket *socket)=0 |
Called when a new connection has been established on socket. If socket is closed in this method, connectionClosed is not called. Must be implemented by subclass. | |
virtual void | connectionClosed (Socket *socket)=0 |
Called when connection to client is closed on socket. Must be implemented by subclass. | |
Private Member Functions | |
void | closeSocket (Socket *s) |
Close client socket s and remove client from list. | |
Private Attributes | |
Socket * | serverSocket |
The server socket on which we listen. | |
std::list< Socket * > | clients |
The list of connected clients. |