This class extends CdcSocket, it implements a server socket. More...
#include <DcSocketServer.h>
Public Member Functions | |
virtual | ~CdcSocketServer () |
The Destructor just decrease the object counter by one. | |
CdcSocket * | Listen () throw (CdcException) |
This function listens to the port, until a client connects to the server. | |
CdcSocket * | ListenNonBlock (int wait=0) throw (CdcException) |
This function is the same as Listen but it returns after wait mSec. | |
Static Public Member Functions | |
static CdcSocketServer * | GetSocketServer (int port) throw (CdcException) |
This is a static function to create (just one) dynamically allocated object from this class, and get a pointer to the object. | |
static CdcSocketServer * | GetSocketServer () throw (CdcException) |
Protected Member Functions | |
CdcSocketServer () | |
Empty constructor. |
This class extends CdcSocket, it implements a server socket.
This socket can listen to an incoming connection on a specific port, and creates a connection to the client with a CdcSocket object. The only way to create an object from this class is to call CdcSocketserver::GetSocketServer. You can create just one object from this class (singleton), and the user has to delete the object when she is done .
Definition at line 45 of file DcSocketServer.h.
CdcSocketServer::CdcSocketServer | ( | ) | [inline, protected] |
Empty constructor.
The only way to create object from this class, is calling the static function GetSocketServer.
Definition at line 56 of file DcSocketServer.h.
virtual CdcSocketServer::~CdcSocketServer | ( | ) | [inline, virtual] |
The Destructor just decrease the object counter by one.
Definition at line 62 of file DcSocketServer.h.
CdcSocketServer * CdcSocketServer::GetSocketServer | ( | int | port ) | throw (CdcException) [static] |
This is a static function to create (just one) dynamically allocated object from this class, and get a pointer to the object.
The object is initialized to listen to a port.
The user has to delete this object when he is done.
port | The port to listen to. |
(CdcException) | Error number from the OS socket API, or 'More than one Object' exception. |
Definition at line 32 of file DcSocketServer.cpp.
CdcSocketServer * CdcSocketServer::GetSocketServer | ( | ) | throw (CdcException) [static] |
Definition at line 66 of file DcSocketServer.cpp.
CdcSocket * CdcSocketServer::Listen | ( | ) | throw (CdcException) |
This function listens to the port, until a client connects to the server.
Then it returns a pointer to a CdcSocket object that is connected to this client. The function blocks infinitely.
The user has to delete the returned object when he is done.
(CdcException) | Error number from the OS socket API. |
Definition at line 72 of file DcSocketServer.cpp.
CdcSocket * CdcSocketServer::ListenNonBlock | ( | int | wait = 0 ) |
throw (CdcException) |
This function is the same as Listen but it returns after wait mSec.
If there was no connection, it returns NULL. Internally it uses the select command.
wait | The time to wait for a connection [mSec]. If the time is 0, the function just poll the socket for a connection. 0 is the default. |
(CdcException) | Error number from the OS socket API. |
Definition at line 95 of file DcSocketServer.cpp.