class CAVERNnet_tcpReflector_c TCP Reflector class
| | init (int incomingPort=TCP_REFLECTOR_DEFAULT_PORT, int maxClients = 64, char* forwardAddr = NULL, unsigned short forwardPort = 0) Initialize the reflector |
| | process () Call this within a while loop to let the reflector continuously do its processing |
| | checkForNewClients () Call this as often as you wish to check for new clients |
| | setForcedDestination (char *ipAddr, unsigned short port) Set a single ip address and port number to which all packets will be sent |
|
| sendToAll (char* buffer, int dataSize) Send data to all clients connected to the reflector |
| | intercept (int (*callback) (CAVERNnet_tcpReflectorClient_c *client, char** buffer, int *bufferSize, void *userData), void* userData) Intercept incoming messages and call a user-defined callback function |
| | interceptNewConnection (void (*callback) (CAVERNnet_tcpReflectorClient_c *newClient, void* userData), void *userData) Intercept any new connections that are formed |
| | showStats (char* streamInfo, char* comment) Displays the resultant statistics instantaneously in the netlogger format - this should be typically done after a read/write is done a network |
| | logStats (char* streamInfo, char* comment, FILE* filePtr) This logs performance statistics in a file |
| | sendStats (char* streamInfo, char* comment) Sends the performance statistics to a remote perfdaemon -for further analysis of the monitored data - the initSendStats API should be called first, before calling a sendStats (In order to connect to the perfdaemon initially) (Note: A typical example of sendStats is given in the (CAVERN_DISTRIB_DIR/demos/tcpreflector/ directory)
|
| | initSendStats (char* monitorClientIP, int port = PERF_DAEMON_DEFAULT_PORT) Initialize sendStats - provide the IP of the perfDaemon and an optional port number to connect to |
|
| exitSendStats () Properly delete the perfDaemonClient after sendStats is done |
| |
|
TCP Reflector class. This class treats TCP streams as discrete packets/messages that can be reflected to multiple connected clients. Clients must be created using CAVERNnet_tcpReflectorClient_c in order to interpret the TCP stream correctly. Hence do NOT attempt to use CAVERNnet_tcpClient_c to connect to a TCP reflector or it will corrupt the TCP reflector stream. This reflector has 2 main functions: checkForNewClients() and process(). checkForNewClients, as the name suggests, checks to see if any new clients wish to connect to the reflector. Process() does the actual work of data reflection.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.
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_tcpReflectorClient_c object that
can then be used to send data directly to the client that originally sent the message.
Also, it should be noted that a showStats call should be made at the end of atleast one send and receive for two-way information (the same applies for logStats and sendStats)
(Note: A typical example of sendStats is given in the (CAVERN_DISTRIB_DIR/demos/tcpreflector/ directory)
int process()
int checkForNewClients()
int setForcedDestination(char *ipAddr, unsigned short port)
void intercept(int (*callback) (CAVERNnet_tcpReflectorClient_c *client, char** buffer, int *bufferSize, void *userData), void* userData)
void interceptNewConnection(void (*callback) (CAVERNnet_tcpReflectorClient_c *newClient, void* userData), void *userData)
void showStats(char* streamInfo, char* comment)
comment -
A comment on the event that marks the time at which the stream is being monitored
int logStats(char* streamInfo, char* comment, FILE* filePtr)
comment -
A comment on the event that marks the time at which the stream is being monitored
filePtr -
File pointer to the file in which the results of monitoring are to be stored
int sendStats(char* streamInfo, char* comment)
comment -
A comment on the event that marks the time at which the stream is being monitored
int initSendStats(char* monitorClientIP, int port = PERF_DAEMON_DEFAULT_PORT)
port -
Port number at which the perfDaemon is running -this is optional. The default port number for perfDaemon is 9500 -so a different port number has to be specified if the perfDaemon is running on a different port.
alphabetic index hierarchy of classes
this page has been generated automatically by doc++
(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de