SockServ Class Reference

This is a multi-socket connection server. More...

#include <Beowulf/SockServ.H>

Inheritance diagram for SockServ:
Inheritance graph
[legend]
Collaboration diagram for SockServ:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SockServ (OptionManager &mgr, const std::string &descrName="Socket Server", const std::string &tagName="SockServ")
 SockServ constructor.
 ~SockServ ()
 SockServ destructor.
int check (const int stimeout, const int utimeout)
 check what's going on
int getNewClient ()
 zero if no more new clients, else client fd
int getReadClient ()
 zero if no more new clients, else client fd
int getWriteClient ()
 zero if no more new clients, else client fd
int getErrorClient ()
 zero if no more new clients, else client fd
in_addr_t getClientIP (const int clifd) const
 get IP address of a client
short int getClientPort (const int clifd) const
 get port of a client
int getRWClient ()
 all wclients first, then all rclients
void disconnect (const int client)
 disconnect a client
bool addUserClient (void *data)
 external users can also add their own new clients:
void * getNewUserClient ()
bool monitorRead (const int client, const bool startstop=true)
 what should we monitor for, for a given connection:
bool monitorWrite (const int client, const bool startstop=true)
 what should we monitor for, for a given connection:
bool monitorError (const int client, const bool startstop=true)
 what should we monitor for, for a given connection:
bool noTimeOut (const int client)
void resetTimeOut (const int client)
void addClient (const int client)
void deleteClient (const int client)

Protected Attributes

OModelParam< short int > itsPort
 My port to listen to.
NModelParam< std::stringitsServ
 Name of service in /etc/services.
NModelParam< std::stringitsServType
 Type of service in /etc/services.
NModelParam< int > itsCliTout
 Timeout on idel clients (in s).
NModelParam< int > itsQlen
 Length of listen queue.

Detailed Description

This is a multi-socket connection server.

This is a multi-socket connection server; it listens onto a master socket and accepts incoming connections; it then can monitor all open connections for read, write and/or error, all in a single call to check(), using a non-blocking select().

Classes using SockServ should call check() to determine which connections require attention. Subsequently, they should take appropriate action on the connections that are active, using getXXXclient(). In adition to the connections that are automatically open by SockServ on accept() on the master socket, users may tell SockServ to monitor additional (already open) connections, by adding them to SockServ's monitor list using addUserClient(). By default, connections time out after CLITIMEOUT time of inactivity. This can be disabled using noTimeOut().

Definition at line 73 of file SockServ.H.


Constructor & Destructor Documentation

SockServ::SockServ ( OptionManager mgr,
const std::string descrName = "Socket Server",
const std::string tagName = "SockServ" 
)

SockServ constructor.

Definition at line 69 of file SockServ.C.

References SOCKSERV_UNCONFIGURED.

SockServ::~SockServ (  ) 

SockServ destructor.

Definition at line 80 of file SockServ.C.


Member Function Documentation

bool SockServ::addUserClient ( void *  data  ) 

external users can also add their own new clients:

Definition at line 292 of file SockServ.C.

References MAXNBNUCLI.

int SockServ::check ( const int  stimeout,
const int  utimeout 
)

check what's going on

Definition at line 151 of file SockServ.C.

References CLITIMEOUT, disconnect(), and SOCKSERV_IDLE.

void SockServ::disconnect ( const int  client  ) 

disconnect a client

Definition at line 277 of file SockServ.C.

Referenced by check().

in_addr_t SockServ::getClientIP ( const int  clifd  )  const

get IP address of a client

Definition at line 251 of file SockServ.C.

short int SockServ::getClientPort ( const int  clifd  )  const

get port of a client

Definition at line 260 of file SockServ.C.

int SockServ::getErrorClient (  ) 

zero if no more new clients, else client fd

Definition at line 247 of file SockServ.C.

int SockServ::getNewClient (  ) 

zero if no more new clients, else client fd

Definition at line 235 of file SockServ.C.

int SockServ::getReadClient (  ) 

zero if no more new clients, else client fd

Definition at line 239 of file SockServ.C.

int SockServ::getRWClient (  ) 

all wclients first, then all rclients

Definition at line 269 of file SockServ.C.

int SockServ::getWriteClient (  ) 

zero if no more new clients, else client fd

Definition at line 243 of file SockServ.C.

bool SockServ::monitorError ( const int  client,
const bool  startstop = true 
)

what should we monitor for, for a given connection:

Definition at line 349 of file SockServ.C.

bool SockServ::monitorRead ( const int  client,
const bool  startstop = true 
)

what should we monitor for, for a given connection:

Definition at line 329 of file SockServ.C.

bool SockServ::monitorWrite ( const int  client,
const bool  startstop = true 
)

what should we monitor for, for a given connection:

Definition at line 339 of file SockServ.C.


Member Data Documentation

Timeout on idel clients (in s).

Definition at line 134 of file SockServ.H.

OModelParam<short int> SockServ::itsPort [protected]

My port to listen to.

Definition at line 131 of file SockServ.H.

NModelParam<int> SockServ::itsQlen [protected]

Length of listen queue.

Definition at line 135 of file SockServ.H.

Name of service in /etc/services.

Definition at line 132 of file SockServ.H.

Type of service in /etc/services.

Definition at line 133 of file SockServ.H.


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:25:44 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3