Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Server Class Referenceabstract

#include <elm/net/ServerSocket.h>

Public Member Functions

 Server (void)
 
 Server (int port)
 
virtual ~Server (void)
 
int port (void) const
 
void open (void)
 
void manage (void)
 
void close (void)
 

Protected Member Functions

virtual void onConnection (Connection &connection)=0
 

Detailed Description

This class provides a way to listen on a port for connection as server. For each connection, a dedicated object is created and the method onConnection() is called: this lets an inheriting class to specialize the processing of this connection.

Constructor & Destructor Documentation

◆ Server() [1/2]

Server ( void  )

Build a server on non-predefined port.

◆ Server() [2/2]

Server ( int  port)

Build a server on the given port.

Parameters
portPort to use.

◆ ~Server()

~Server ( void  )
virtual

References Server::close().

Member Function Documentation

◆ close()

void close ( void  )

Close the connection and stop the managing of the server (end of function manage()).

Referenced by Server::~Server().

◆ manage()

void manage ( void  )

Manage the server, that is, get the incoming connections until it is requested to close.

Exceptions
ExceptionThrown if there is an error during the open.

References ServerSocket::listen(), and Server::onConnection().

◆ onConnection()

void onConnection ( Connection connection)
protectedpure virtual

Called each time a connection arises. The current connection (with input and output streams) is passed to let the application to process it.

Parameters
connectionCreated connection.

Referenced by Server::manage().

◆ open()

void open ( void  )

Open the server.

References ServerSocket::make(), and ServerSocket::open().

◆ port()

int port ( void  ) const
inline

References ServerSocket::port().


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