This is a multi-socket connection server. More...
#include <Beowulf/SockServ.H>
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::string > | itsServ |
Name of service in /etc/services. | |
NModelParam< std::string > | itsServType |
Type of service in /etc/services. | |
NModelParam< int > | itsCliTout |
Timeout on idel clients (in s). | |
NModelParam< int > | itsQlen |
Length of listen queue. |
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.
SockServ::SockServ | ( | OptionManager & | mgr, | |
const std::string & | descrName = "Socket Server" , |
|||
const std::string & | tagName = "SockServ" | |||
) |
SockServ::~SockServ | ( | ) |
SockServ destructor.
Definition at line 80 of file SockServ.C.
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 | ) |
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.
NModelParam<int> SockServ::itsCliTout [protected] |
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.
NModelParam<std::string> SockServ::itsServ [protected] |
Name of service in /etc/services.
Definition at line 132 of file SockServ.H.
NModelParam<std::string> SockServ::itsServType [protected] |
Type of service in /etc/services.
Definition at line 133 of file SockServ.H.