Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_parallelTcpClient_c Class Reference

#include <CAVERNnet_parallelTcp_c.hxx>

Inheritance diagram for CAVERNnet_parallelTcpClient_c::

CAVERNnet_socketbase_c CAVERNnet_extendedParallelTcpClient_c List of all members.

Public Methods

 CAVERNnet_parallelTcpClient_c ()
 ~CAVERNnet_parallelTcpClient_c ()
int write (char *buffer, int *length)
int read (char *buffer, int *length)
void close ()
int connectToServer (char *RemoteName, int RemotePort, int Size)
void setSockets (int *Sockets, int NumSockets)
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
 Operation successful.

const int FAILED
 Operation failed.


Protected Methods

void makeNonBlocking (int Sockfd)
int connectToClient (char *RemoteName, unsigned short RemotePort, int &SocketInfo)

Protected Attributes

char** pcReadPtr
char** pcWritePtr
int* piBytesLeft
int* sockets
fd_set fdSet
int maxSockDesc
int numSockets
struct sockaddr_in remoteAddr
struct sockaddr_in localAddr

Detailed Description

Parallel socket class. This enables us to transfer a stream of data over multiple sockets simultaneously.

Why is this faster than a single socket connection? The TCP protocol requires acknowledgement from the other end everytime it sends a packet, thus it waits for someting on every send. With parallel sockets, while one socket is waiting, another socket connection can send data. We therefore eliminate idle time.

If you are writing a server you need to instantiate a CAVERNnet_parallelTcpServer_c object. Likewise if you are writing a client you need to instantiate a CAVERNnet_parallelTcpClient_c object.

Server setup: First, instantiate the CAVERNnet_parallelTcpServer_c class. Then call this object's init() method with the desired port number as parameter. After this, we call CAVERNnet_parallelTcpServer_c::checkForNewConnections(PortNumber). This is a blocking call that waits for the client to make a CAVERNnet_parallelTcpClient_c::connectToServer() call. checkForNewConnections() returns a pointer to a CAVERNnet_parallelTcpClient_c object, which you can use to communicate with the client. Note that you do not explicitly instantiate a CAVERNnet_parallelTcpClient_c object when you are using the server class. You can just declare a pointer to the client object and assign to this variable the return value of CAVERNnet_parallelTcpServer_c::checkForNewConnections function.

Client setup: We instantiate the CAVERNnet_parallelTcpClient_c class and call the CAVERNnet_parallelTcpClient_c::connectToServer(MachineName,PortNumber,NumberOfSockets) method. We then use this object to do a write and read.

@author: Stuart Bailey, cavern@evl

@version: 2/22/2000


Member Function Documentation

void CAVERNnet_parallelTcpClient_c::close ( )
 

Close down the multiple socket handles

int CAVERNnet_parallelTcpClient_c::connectToServer ( char * RemoteName,
int RemotePort,
int Size )
 

We instantiate a CAVERNnet_parallelTcpClient_c object and calls this connectToServer() method to connect to machine named "RemoteName" on port Port. We specify the number of simultaneous socket connections in the Size parameter. After this call is successfully called, you can then use read and write methods.

Parameters:
RemoteName   A character string, name of the machine where the remote server is.
Port   Port number which the remote server is listening to.
Size   The number of simultaneous sockets we are to use.

Returns:
Either CAVERNnet_parallelTcpClient_c::OK or CAVERNnet_parallelTcpClient_c::FAILED

void CAVERNnet_parallelTcpClient_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_parallelTcpClient_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_parallelTcpClient_c::read ( char * buffer,
int * length )
 

After returning from checkForNewConnections() or after calling connectToServer(), you can now call write() to send Length bytes of data starting at Buffer

Returns:
Either CAVERNnet_parallelTcpClient_c::OK or CAVERNnet_parallelTcpClient_c::FAILED
Parameters:
Buffer   A pointer to the buffer that will store the received data.
Length   Number of bytes to be received.

int CAVERNnet_parallelTcpClient_c::write ( char * buffer,
int * length )
 

After returning from checkForNewConnections() or after calling connectToServer(), you can now call write() to send Length bytes of data starting at Buffer

Returns:
Either CAVERNnet_parallelTcpClient_c::OK or CAVERNnet_parallelTcpClient_c::FAILED
Parameters:
Buffer   A pointer to the buffer to be sent.
Length   Number of bytes to be sent.


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