Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_tcpClient_c Class Reference

#include <CAVERNnet_tcp_c.hxx>

Inheritance diagram for CAVERNnet_tcpClient_c::

CAVERNnet_socketbase_c CAVERNnet_extendedTcpClient_c List of all members.

Public Methods

void setTimeOut (int t)
int getTimeOut ()
 Get timeout period.

void setClientInfo (struct sockaddr_in *info)
void setClientSockFd (int sockfd)
 CAVERNnet_tcpClient_c ()
 ~CAVERNnet_tcpClient_c ()
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)
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 ()
void setInstantaneousLatency (double latency)
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.

Read and Write calls.
int read (char *ptr, int *nbytes, int blockingType)
void setSockOptions (int option, int buffersize)
int isReadyToRead ()
int isReadyToWrite ()
int isReady ()
int write (char *ptr, int *nbytes, int blockingType)

Static Public Attributes

const int BLOCKING
 Make the connection blocking but time out eventually.

const int NON_BLOCKING
 Make the connection non blocking.

const int NO_TIME_OUT
 Used to set time out period to never time out.

const int DEFAULT_TIME_OUT
 Default time out is no time out.

const int SOCKET_NOT_OPEN
 Socket is not open.

const int CONNECTION_TERMINATED
 Connection you attempted to read/write is terminated.

const int NON_BLOCKING_HAS_NO_DATA
 You attempted to read with non blocking and there was not data.

const int TIMED_OUT
 The read/write timed out.

const int OK
 Read/Write succeeded.

const int NON_BLOCKING_NOT_READY_TO_WRITE
 You attempted to write with non blocking and socket was not ready.

const int NOT_READY
 Socket was not ready.

const int READY_TO_READ
 Socket ready to read.

const int READY_TO_WRITE
 Socket ready to write.

const int READY_TO_READ_AND_WRITE
 Socket ready to read and write.

const int READ_BUFFER_SIZE
 Change the socket buffer size before Read().

const int WRITE_BUFFER_SIZE
 Change the socket buffer size before Write().


Protected Methods

void makeNonBlocking ()

Protected Attributes

struct sockaddr_in clientInfo
int clientSockFd
int clientStatus
int timeOutStatus
int timeOutPeriod
CAVERNnet_perfMonitor_c pmonitor

Friends

class CAVERNnet_tcpServer_c

Detailed Description

TCP Class for creating client connections. This class bypasses CAVERN's standard method for establishing connections and provides the user with direct control of TCP connections.


Member Function Documentation

int CAVERNnet_tcpClient_c::connectToServer ( char * ip,
int port )
 

Connect to a server.

Returns:
A negative number(that is returned by a socket sonnect() call if failed. Else returns client's socket file descriptor. (note: the return value in the previous versions was a zero in case of an error - this has been changed to a negative value from version 1.2)

void CAVERNnet_tcpClient_c::exitSendStats ( )
 

Properly delete the perFDaemon Client after sendStats is done

void CAVERNnet_tcpClient_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_tcpClient_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_tcpClient_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 ona different port.

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

int CAVERNnet_tcpClient_c::isReady ( )
 

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

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

int CAVERNnet_tcpClient_c::isReadyToRead ( )
 

Determines if a socket has data available to read.

Returns:
Either: CAVERNnet_tcpClient_c::NOT_READY or CAVERNnet_tcpClient_c::READY_TO_READ

int CAVERNnet_tcpClient_c::isReadyToWrite ( )
 

Determines if a socket is ready to write.

Returns:
Either: CAVERNnet_tcpClient_c::NOT_READY or CAVERNnet_tcpClient_c::READY_TO_WRITE

int CAVERNnet_tcpClient_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_tcpClient_c::read ( char * ptr,
int * nbytes,
int blockingType )
 

Parameters:
nbytes   Fill nbytes with num bytes you want to read. nbytes will return with number of bytes successfully read.
blockingtype   BLOCKING means that it will block waiting for data or until the timeout period expires. Change the timeout period by calling setTimeOut().

NON_BLOCKING means that if there is no data to be read this call will return immediately. If it does get some data it will keep reading until the specified number of bytes is received, or if it timesout, or if the connection is broken. In the latter two cases the number of bytes it was able to read is returned.

In either the BLOCKING or NON_BLOCKING case you can set the time out period to never time out by setting the timeout time to: NO_TIME_OUT.

Returns:
SOCKET_NOT_OPEN, NON_BLOCKING_HAS_NO_DATA, TIMED_OUT, CONNECTION_TERMINATED, OK, errno

int CAVERNnet_tcpClient_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)

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_tcpClient_c::setClientInfo ( struct sockaddr_in * info ) [inline]
 

Set client info. For internal use.

Parameters:
info   client information

void CAVERNnet_tcpClient_c::setClientSockFd ( int sockfd ) [inline]
 

Set client socket. For internal use.

Parameters:
sockfd   client socket

void CAVERNnet_tcpClient_c::setSockOptions ( int option,
int buffersize )
 

Allows you to change the parameters to the setsockopt() options.Currently this member allows you to change socket buffer size.

Parameters:
option   Specify CAVERNnet_tcpClient_c::READ_BUFFER_SIZE if you want to change the size of the receive buffer Specify CAVERNnet_tcpClient_c::WRITE_BUFFER_SIZE if you want to change the size of the send buffer
buffersize   Specify the size.

void CAVERNnet_tcpClient_c::setTimeOut ( int t ) [inline]
 

Set timeout period when performing read() or write() operations.

Parameters:
t   Time out period in seconds. Set to CAVERNnet_tcpClient_c::NO_TIME_OUT to set no time out period.

void CAVERNnet_tcpClient_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 over 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_tcpClient_c::write ( char * ptr,
int * nbytes,
int blockingType )
 

Write data to socket.

Returns:
SOCKET_NOT_OPEN, NON_BLOCKING_NOT_READY_TO_WRITE, TIMED_OUT, CONNECTION_TERMINATED, OK


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