Extending the TCP class


Introduction

       Here the TCP classes have been enhanced to help users minimize the effort of packing and unpacking numerical values before they are sent. The methods in the extended classes pack values before sending them out on the network and unpack the values before the user accesses them. Otherwise the user will have to perform the packing and unpacking of data. This demo illustrates how various data types can be safely transported from one point to another with the help of the methods in the extended classes.


CAVERNsoft classes used

    CAVERNnet_extendedTcpServer_c

                 This class is derived from the CAVERNnet_tcpServer_c class. The port number on which the server is to be opened is given to the init() method. After this we can use the checkForNewConnections() method to look for incoming client connections. It is better to use the extended class instead of CAVERNnet_tcpServer_c since CAVERNnet_extendedTcpServer_c gives you access to all methods available in the CAVERNnet_extendedTcpClient_c class.

    CAVERNnet_extendedTcpClient_c

                A client can be created using this class which is derived from the CAVERNnet_tcpClient_c class. It can connect to the server by using connectToServer(). You can read or write data of various types using the methods in this class - character, integer, array of integers, 32 bit integer, array of 32 bit integers, 64 bit integers, array of 64 bit integers, long integer, array of long integer, single precision floating point value, array of float values, double precision floating point value or an array of double precision floating point values. You can choose the mode of the I/O operation (blocking or non blocking).

                The server.cxx sets up the server and using a pointer to an object of CAVERNnet_extendedTcpClient_c arranges to send various data values. The client.cxx program intercepts the data and prints them out (no packing ! no unpacking! ).


Usage

 1. To run the server
          server

 2. To run a client
          client <server address>

Output

        When the server.cxx and client.cxx programs are run, the various data sent and received are displayed. A sample follows :
                At server :
                        Send Long: 10000000
                        Send Long Array
                        array[0] = 1000000
                        array[1] = 200000
                        array[2] = 3000000
                        array[3] = 4000000

                At client :
                        Received Long: 10000000
                        Received Long Array
                        array[0] = 1000000
                        array[1] = 200000
                        array[2] = 3000000
                        array[3] = 4000000


for more information email : cavern@evl.uic.edu