Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_parallelTcpServer_c Class Reference

#include <CAVERNnet_parallelTcp_c.hxx>

Inheritance diagram for CAVERNnet_parallelTcpServer_c::

CAVERNnet_socketbase_c CAVERNnet_extendedParallelTcpServer_c List of all members.

Public Methods

 CAVERNnet_parallelTcpServer_c ()
 ~CAVERNnet_parallelTcpServer_c ()
int init (int port)
void close ()
 Close the server port.

CAVERNnet_parallelTcpClient_ccheckForNewConnections ()
unsigned int getSelfIP ()
 Get IP address of self.

int getSelfPort ()
 Get port of self.


Static Public Attributes

const int OK
 Status ok.

const int FAILED
 Status failed.


Protected Methods

void makeNonBlocking (int Sockfd)
int connectToClient (unsigned long RemoteAddr, unsigned short RemotePort, int &SocketInfo)

Protected Attributes

struct sockaddr_in serverInfo
int sockfd

Detailed Description

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.


Member Function Documentation

CAVERNnet_parallelTcpClient_c * CAVERNnet_parallelTcpServer_c::checkForNewConnections ( )
 

Check to see if there is a request from clients for connection. If yes then return a CAVERNnet_parallelTcpClient_c object which you can then use to talk to the client.

See also:
CAVERNnet_parallelTcpClient_c class.

Reimplemented in CAVERNnet_extendedParallelTcpServer_c.

int CAVERNnet_parallelTcpServer_c::init ( int port )
 

Open the server on a port. Typically after this call you sit in a loop and call checkForNewConnections to wait for incoming connections.

Returns:
FAILED if failed, OK if success


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