class CAVERNplus_tcpClient_c : public CAVERNplus_socketbase_c

TCP Class for creating client connections

Inheritance:


Public Methods

void close ()
Close the current client connection.
int connectToServer (char *ip, int port)
Connect to a server
int getTimeOut ()
Get timeout period
void setTimeOut (int t)
Set timeout period when performing read() or write() operations
void showStatus (int status, int nbytes)
Show status of connection in English.

Public


Return values from Read/Write methods.
const int CAVERNplus_tcpClient_c::SOCKET_NOT_OPEN
Socket is not open.
const int CAVERNplus_tcpClient_c::CONNECTION_TERMINATED
Connection you attempted to read/write is terminated.
const int CAVERNplus_tcpClient_c::NON_BLOCKING_HAS_NO_DATA
You attempted to read with non blocking and there was not data.
const int CAVERNplus_tcpClient_c::TIMED_OUT
The read/write timed out.
const int CAVERNplus_tcpClient_c::OK
Read/Write succeeded.
const int CAVERNplus_tcpClient_c::NON_BLOCKING_NOT_READY_TO_WRITE
You attempted to write with non blocking and socket was not ready.
const int CAVERNplus_tcpClient_c::NOT_READY
Socket was not ready.
const int CAVERNplus_tcpClient_c::READY_TO_READ
Socket ready to read.
const int CAVERNplus_tcpClient_c::READY_TO_WRITE
Socket ready to write.
const int CAVERNplus_tcpClient_c::READY_TO_READ_AND_WRITE
Socket ready to read and write.

Accessor functions
unsigned int getRemoteIP ()
Get the IP address of remote connection
void getRemoteIP (char* name)
Get the IP address of remote connection
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.

Time out values.
const int CAVERNplus_tcpClient_c::NO_TIME_OUT
Used to set time out period to never time out.
const int CAVERNplus_tcpClient_c::DEFAULT_TIME_OUT
Default time out is no time out.

Blocking parameter values for Read/Write method.
const int CAVERNplus_tcpClient_c::BLOCKING
Make the connection blocking but time out eventually.
const int CAVERNplus_tcpClient_c::NON_BLOCKING
Make the connection non blocking.
Read and Write calls.
int read (char *ptr, int *nbytes, int blockingType)
int isReadyToRead ()
Determines if a socket has data available to read
int isReadyToWrite ()
Determines if a socket is ready to write
int isReady ()
Determines if a socket is ready to write or read or both
int write (char *ptr, int *nbytes, int blockingType)
Write data to socket

Inherited from CAVERNplus_socketbase_c:

Public Methods

void expandHostName(char *src, char *newname, int len)
double getAverageReceiveBandwidth()
double getAverageSendBandwidth()
void getHostName(char *name, int len)
double getInstantReceiveBandwidth()
double getInstantSendBandwidth()
double getTimeInSecs()
unsigned long getTotalDataReceived()
unsigned long getTotalDataSent()
int hostnameToIP(char *hostname, char* hostIP)
void ipNumToString(unsigned int ip, char *ipstring)
void showStats()

Documentation

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.
void setTimeOut(int t)
Set timeout period when performing read() or write() operations
Parameters:
t - Time out period in seconds. Set to CAVERNplus_tcpClient_c::NO_TIME_OUT to set no time out period.

unsigned int 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.

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

Read and Write calls.

int read(char *ptr, int *nbytes, int blockingType)
Returns:
See return status values.
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.

int isReadyToRead()
Determines if a socket has data available to read
Returns:
Either: CAVERNplus_tcpClient_c::NOT_READY or CAVERNplus_tcpClient_c::READY_TO_READ

int isReadyToWrite()
Determines if a socket is ready to write
Returns:
Either: CAVERNplus_tcpClient_c::NOT_READY or CAVERNplus_tcpClient_c::READY_TO_WRITE

int isReady()
Determines if a socket is ready to write or read or both
Returns:
Either: CAVERNplus_tcpClient_c::NOT_READY or CAVERNplus_tcpClient_c::READY_TO_WRITE or CAVERNplus_tcpClient_c::READY_TO_READ or CAVERNplus_tcpClient_c::READY_TO_READ_AND_WRITE

int write(char *ptr, int *nbytes, int blockingType)
Write data to socket
See Also:
Read().

int connectToServer(char *ip, int port)
Connect to a server
Returns:
0 if failed.


This class has no child classes.

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