Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_tcpReflectorClient_c Class Reference

#include <CAVERNnet_tcpReflector_c.hxx>

List of all members.

Public Methods

 CAVERNnet_tcpReflectorClient_c ()
 CAVERNnet_tcpReflectorClient_c (CAVERNnet_tcpClient_c *)
 Use this constructor if you have a pre-opened socket.

 ~CAVERNnet_tcpReflectorClient_c ()
int read (char **ret, int *nbytes, int blockingType)
int write (char *outgoingData, int *nbytes)
int isReadyToRead ()
int isReadyToWrite ()
int isReady ()
void showStatus (int status, int nbytes)
 Show status of connection in English.

void close ()
 Close the current client connection.

int connectToServer (char *ip, int port=CAVERNnet_tcpReflector_c::DEFAULT_PORT)
void setTimeOut (int timeout=CAVERNnet_tcpReflectorClient_c::NO_TIME_OUT)
void showStats (char *streamInfo, char *comment)
int logStats (char *streamInfo, char *comment, FILE *filePtr)
int sendStats (char *streamInfo, char *comment)
int initSendStats (char *monitorClientIP, int port=PERF_DAEMON_DEFAULT_PORT)
void exitSendStats ()
unsigned int getRemoteIP ()
void getRemoteIP (char *name)
unsigned int getSelfIP ()
 Get IP address of self.

void getSelfIP (char *name)
 Get IP address of self.

int getSelfPort ()
 Get port of self.

int getRemotePort ()
 Get port of client.


Static Public Attributes

const int OK
 Status ok.

const int FAILED
 Status failed.

const int MEM_ALLOC_ERR
 Memory allocation error.

const int NON_BLOCKING_HAS_NO_DATA
 A non-blocking read had no data available to read.

const int CONNECTION_TERMINATED
 Connection terminated.

const int NOT_READY
 Connection not ready for use.

const int READY_TO_READ
 Connection has data available to read.

const int READY_TO_WRITE
 Connection is ready to write.

const int READY_TO_READ_AND_WRITE
 Connection has data available to read and is ready to write.

const int BLOCKING
const int NON_BLOCKING
const int NO_TIME_OUT

Private Attributes

CAVERNnet_tcpClient_cclient
int timeOut
int connectionAlive


Detailed Description

Client specifically for use with CAVERNnet_tcpReflector_c. Use this only to communicate with the reflector. Do not use the CAVERNnet_tcpClient_c class.

See also:
CAVERNnet_tcpReflector_c


Member Function Documentation

int CAVERNnet_tcpReflectorClient_c::connectToServer ( char * ip,
int port = CAVERNnet_tcpReflector_c::DEFAULT_PORT )
 

Connect to a server.

Parameters:
ip   IP address to connect to.
port   Port to connect to.
Returns:
Either: CAVERNnet_tcpReflectorClient_c::OK or FAILED

void CAVERNnet_tcpReflectorClient_c::exitSendStats ( )
 

Properly delete the perfDaemonClient after sendStats is done

void CAVERNnet_tcpReflectorClient_c::getRemoteIP ( char * name )
 

Get the IP address of remote connection. If you are a client this returns the ip of the destination server. If you are a server this returns the ip of the destination client.

unsigned int CAVERNnet_tcpReflectorClient_c::getRemoteIP ( )
 

Get the IP address of remote connection. If you are a client this returns the ip of the destination server. If you are a server this returns the ip of the destination client.

int CAVERNnet_tcpReflectorClient_c::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. This should be done initially before using the sendStats API.

Parameters:
monitorClientIP   IP address of the perfDameon to connect to
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.

Returns:
Either CAVERNnet_perfMonitor_c::OK or CAVERNnet_perfMonitor_c::FAILED

int CAVERNnet_tcpReflectorClient_c::isReady ( )
 

Determines if a socket is ready to write or read or both.

Returns:
Either: CAVERNnet_tcpReflectorClient_c::NOT_READY or CAVERNnet_tcpReflectorClient_c::READY_TO_WRITE or CAVERNnet_tcpReflectorClient_c::READY_TO_READ or CAVERNnet_tcpReflectorClient_c::READY_TO_READ_AND_WRITE

int CAVERNnet_tcpReflectorClient_c::isReadyToRead ( )
 

Determines if a socket has data available to read.

Returns:
Either: CAVERNnet_tcpReflectorClient_c::NOT_READY or CAVERNnet_tcpReflectorClient_c::READY_TO_READ

int CAVERNnet_tcpReflectorClient_c::isReadyToWrite ( )
 

Determines if a socket is ready to write.

Returns:
Either: CAVERNnet_tcpReflectorClient_c::NOT_READY or CAVERNnet_tcpReflectorClient_c::READY_TO_WRITE

int CAVERNnet_tcpReflectorClient_c::logStats ( char * streamInfo,
char * comment,
FILE * filePtr )
 

This logs performance statistics in a file. The user opens a file and passes the file pointer with this function and results of monitoring are written into the logfile.

Parameters:
streamInfo   A label describing the stream that is being monitored.
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

Returns:
Either CAVERNnet_perfMonitor_c::OK or CAVERNnet_perfMonitor_c::FAILED

int CAVERNnet_tcpReflectorClient_c::read ( char ** ret,
int * nbytes,
int blockingType )
 

Read data from a reflector (if available).

Parameters:
blockingType   set to either CAVERNnet_tcpReflectorClient_c::BLOCKING, NON_BLOCKING.
ret   set to a pointer to a char*. Read will allocate memory for the buffer and assign it to your pointer. You are responsible for deleteing the buffer once you are done with it.
nbytes   returns the number of bytes in the buffer.
Returns:
Either CAVERNnet_tcpReflectorClient_c::MEM_ALLOC_ERR, OK, FAILED, NON_BLOCKING_HAS_NO_DATA, CONNECTION_TERMINATED.

int CAVERNnet_tcpReflectorClient_c::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)

Parameters:
streamInfo   A label describing the stream that is being monitored.
comment   A comment on the event that marks the time at which the stream is being monitored

Returns:
Either CAVERNnet_perfMonitor_c::OK or CAVERNnet_perfMonitor_c::FAILED

void CAVERNnet_tcpReflectorClient_c::setTimeOut ( int timeout = CAVERNnet_tcpReflectorClient_c::NO_TIME_OUT )
 

Set timeout for read and writes. By default no time out is set. Setting time out means that if the read or write is unsuccessful after a certain amount of time the connection will be terminated. This is to prevent you from doing subsequent writes or reads from the stream and getting incorrect data. In order to re-establish the connection you need to instantiate another object of this type.

void CAVERNnet_tcpReflectorClient_c::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.

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)

Parameters:
streamInfo   A label describing the stream that is being monitored.
comment   A comment on the event that marks the time at which the stream is being monitored

int CAVERNnet_tcpReflectorClient_c::write ( char * outgoingData,
int * nbytes )
 

Write data to the reflector.

Parameters:
outgoingData   set to your buffer containing data.
nbytes   set to size of the buffer refered to by outgoingData
Returns:
Either CAVERNnet_tcpReflectorClient_c::OK,CONNECTION_TERMINATED.


The documentation for this class was generated from the following file:
Generated at Mon Jul 2 14:24:45 2001 for CAVERNsoft by doxygen1.2.8-20010617 written by Dimitri van Heesch, © 1997-2001