class CAVERNplus_tcpReflectorClient_c

Client specifically for use with CAVERNplus_tcpReflector_c

Public Methods

CAVERNplus_tcpReflectorClient_c (CAVERNplus_tcpClient_c *)
Use this constructor if you have a pre-opened socket.
void close ()
Close the current client connection.
int connectToServer (char *ip, int port=7000)
Connect to a server
int isReady ()
Determines if a socket is ready to write or read or both
int isReadyToRead ()
Determines if a socket has data available to read
int isReadyToWrite ()
Determines if a socket is ready to write
int read (char** ret, int* nbytes, int blockingType)
Read data from a reflector (if available)
void setTimeOut (int timeout=CAVERNplus_tcpReflectorClient_c::NO_TIME_OUT)
Set timeout for read and writes
void CAVERNplus_tcpReflectorClient_c :: showStats ()
Show statistics of a connection.
void showStatus (int status, int nbytes)
Show status of connection in English.
int write (char *outgoingData, int* nbytes)
Write data to the reflector

Public


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.

const int CAVERNplus_tcpReflectorClient_c::OK
Status ok.
const int CAVERNplus_tcpReflectorClient_c::FAILED
Status failed.
const int CAVERNplus_tcpReflectorClient_c::MEM_ALLOC_ERR
Memory allocation error.
const int CAVERNplus_tcpReflectorClient_c::NON_BLOCKING_HAS_NO_DATA
A non-blocking read had no data available to read.
const int CAVERNplus_tcpReflectorClient_c::CONNECTION_TERMINATED
Connection terminated.
const int CAVERNplus_tcpReflectorClient_c::NOT_READY
Connection not ready for use.
const int CAVERNplus_tcpReflectorClient_c::READY_TO_READ
Connection has data available to read.
const int CAVERNplus_tcpReflectorClient_c::READY_TO_WRITE
Connection is ready to write.
const int CAVERNplus_tcpReflectorClient_c::READY_TO_READ_AND_WRITE
Connection has data available to read and is ready to write.

Documentation

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

int read(char** ret, int* nbytes, int blockingType)
Read data from a reflector (if available)
Returns:
Either CAVERNplus_tcpReflectorClient_c::MEM_ALLOC_ERR, OK, FAILED, NON_BLOCKING_HAS_NO_DATA, CONNECTION_TERMINATED.
Parameters:
blockingType - set to either CAVERNplus_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.

int write(char *outgoingData, int* nbytes)
Write data to the reflector
Returns:
Either CAVERNplus_tcpReflectorClient_c::OK,CONNECTION_TERMINATED.
Parameters:
outgoingData - set to your buffer containing data.
nbytes - set to size of the buffer refered to by outgoingData

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

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

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

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.

int connectToServer(char *ip, int port=7000)
Connect to a server
Returns:
Either: CAVERNplus_tcpReflectorClient_c::OK or FAILED
Parameters:
ip - IP address to connect to.
port - Port to connect to.

void setTimeOut(int timeout=CAVERNplus_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.


This class has no child classes.
See Also:
CAVERNplus_tcpReflector_c

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