Public Member Functions | Static Public Member Functions | Protected Member Functions

CdcSocketServer Class Reference

This class extends CdcSocket, it implements a server socket. More...

#include <DcSocketServer.h>

Inheritance diagram for CdcSocketServer:
CdcSocket

List of all members.

Public Member Functions

virtual ~CdcSocketServer ()
 The Destructor just decrease the object counter by one.
CdcSocketListen () throw (CdcException)
 This function listens to the port, until a client connects to the server.
CdcSocketListenNonBlock (int wait=0) throw (CdcException)
 This function is the same as Listen but it returns after wait mSec.

Static Public Member Functions

static CdcSocketServerGetSocketServer (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 CdcSocketServerGetSocketServer () throw (CdcException)

Protected Member Functions

 CdcSocketServer ()
 Empty constructor.

Detailed Description

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 .

Author:
Erez Bibi
Version:
1.0

Definition at line 45 of file DcSocketServer.h.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

Parameters:
portThe port to listen to.
Returns:
(CdcSocketServer*) Pointer to a new SocketServer object.
Exceptions:
(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.

Returns:
(CdcSocket*) A pointer to a new CdcSocket object.
Exceptions:
(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.

Parameters:
waitThe 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.
Returns:
(CdcSocket*) A pointer to a new CdcSocket object. or NULL if there was no connection.
Exceptions:
(CdcException)Error number from the OS socket API.

Definition at line 95 of file DcSocketServer.cpp.


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