#include <CAVERNnet_perfDaemon_c.hxx>
Public Methods | |
CAVERNnet_perfDaemon_c (FILE *File=NULL) | |
~CAVERNnet_perfDaemon_c () | |
int | init (int incomingPort=PERF_DAEMON_DEFAULT_PORT, int maxClients=64) |
int | process () |
int | checkForNewClients () |
void | intercept (int(*callback)(CAVERNnet_perfDaemonClient_c *client, char **buffer, int *bufferSize, void *userData), void *userData) |
void | interceptNewConnection (void(*callback)(CAVERNnet_perfDaemonClient_c *newClient, void *userData), void *userData) |
int | sendToAll (char *buf, int incomingSize) |
Static Public Attributes | |
const int | OK |
Status ok. | |
const int | FAILED |
Status failed. | |
const int | MEM_ALLOC_ERR |
Memory allocation error. | |
const int | NEW_CONNECTION_ESTABLISHED |
New client has been connected. | |
const int | TOO_MANY_CLIENTS |
Reflector cannot handle any more connections. | |
const int | NO_NEW_CONNECTION |
No new connection. | |
const int | NON_BLOCKING_HAS_NO_DATA |
A non-blocking read had no data available to read. | |
const int | SKIP_DISTRIBUTION |
Skip the data distribution process. Used in user callback. See intercept(). | |
const int | DEFAULT_PORT |
Private Methods | |
int | distributeDataToPerfClients (char *buf, int incomingSize) |
void | removeClient (int clientNum) |
void | closeDownSockets () |
Private Attributes | |
PerfDaemonClient** | clients |
CAVERNnet_tcpServer_c* | server |
unsigned short | incomingPort |
FILE* | LogFile |
int (* | interceptCallback )(CAVERNnet_perfDaemonClient_c *newClient, char **buffer, int *bufsize, void *userData) |
void* | interceptUserData |
void (* | interceptNewConnectionCallback )(CAVERNnet_perfDaemonClient_c *newClient, void *userData) |
void* | interceptNewConnectionUserData |
int | maxNumClients |
checkForNewClients is called everytime process() is called. If you want the check to be done more frequently you need to do it yourself. Similarly if you want the process() call done more frequently it is up to you to do it. I recommend threading those two off and setting up a mutex so that you do not do process() and checkForNewClients() at the same time.
|
Constructor of performance monitoring daemon class.
|
|
Call this as often as you wish to check for new clients. Note. If you do this in a separate thread then you must set up a mutex so that you do not call the proces() call and this call at the same time. The process() call itself has imbedded in it 1 check for each time you call it.
|
|
Initialize the reflector.
|
|
Intercept incoming messages and call a user-defined callback function. If you want you can also alter the buffer completely so that the reflector will reflect an entirely different message. You can do this by changing the contents of the buffer or by replacing the buffer entirely by allocating memory for a new buffer and stuffing it with your own data. If you choose to allocate a totally new buffer you must remember to deallocate memory for the original buffer before substituting it with yours. If after your callback function exits you do not wish the reflector to forward the contents of the buffer, return with CAVERN_tcpReflector_c::SKIP_DISTRIBUTION. Otherwise just return CAVERN_tcpReflector_c::OK. Note also that the callback function will also be given a pointer to a CAVERNnet_perfDaemonClient_c object that can then be used to send data directly to the client that originally sent the message. |
|
Intercept any new connections that are formed. This allows you to send private data to the newly formed connection before it assumes its data reflection duties. Callback function will be given a pointer to the CAVERNnet_perfDaemonClient_c object that can then be used to send data directly to the client. |
|
Call this within a while loop to let the reflector continuously do its processing.
|