#include <CAVERNnet_parallelTcp_c.hxx>
Inheritance diagram for CAVERNnet_parallelTcpClient_c::
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 |
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
|
Close down the multiple socket handles |
|
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.
|
|
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. |
|
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. |
|
After returning from checkForNewConnections() or after calling connectToServer(), you can now call write() to send Length bytes of data starting at Buffer
|
|
After returning from checkForNewConnections() or after calling connectToServer(), you can now call write() to send Length bytes of data starting at Buffer
|