#include <CAVERNnet_parallelTcp_c.hxx>
Inheritance diagram for CAVERNnet_parallelTcpServer_c::
Public Methods | |
CAVERNnet_parallelTcpServer_c () | |
~CAVERNnet_parallelTcpServer_c () | |
int | init (int port) |
void | close () |
Close the server port. | |
CAVERNnet_parallelTcpClient_c* | checkForNewConnections () |
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 |
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.
|
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.
Reimplemented in CAVERNnet_extendedParallelTcpServer_c. |
|
Open the server on a port. Typically after this call you sit in a loop and call checkForNewConnections to wait for incoming connections.
|