"tcp" in my "cs3392" directory contains programs to teach you 
socket based communication between a client
and a server using the TCP protocols. These programs are taken
from chapter 6 of "UNIX Network Programming" by Stevens.

The programs implement a trivial application: client reads
user-typed input from standard input (terminal), sends it to
the server, and server echos it back, which the client displays
back onto the terminal. 
-----------------------------------------------------------
BUILDING THE CODE

The source code is divided in 8 files - there are two skeleton
client and server programs, two support programs (strecho called
by the server and strcli called by the client), and three
utility programs. There is one header file also. To do the
project, follow the steps given below (commands to be run are
included with in pair of "..."; do not type quotes:

Create a directory by running command - "mkdir tcp" - change to
tcp and run the following to copy all files in
the current directory, denoted by ".".
"cp ~lakhani/cs3393/tcp/* ."

Next You need to update the header file.
Suppose that you decide to run the server on a host, say,
mars.cs.ttu.edu. You would need the IP address of this host.
Run "niscat hosts.org_dir|grep mars"
to list IP address of mars in cs.ttu.edu domain. 
Modify the file "inet.h" for your server to run on mars.
Also modify the port number. Your server should not share the port
with anyone. (use yymm as port#, where yy and mm denote
the year and month of your birth).

Next Compile all files using 
"gcc -c *.c"

Now build client and server programs.

gcc -o SERV tcpserv.o strecho.o readline.o writen.o readn.o -lnsl -lsocket 
gcc -o CLI tcpcli.o strcli.o readline.o writen.o readn.o -lnsl -lsocket 
---------------------------------------------------------------
RUNNING THE PROGRAMS

Open a new window and "rlogin mars" to open a remote 
connection to "mars".  Run  the server (type "./SERV &" and hit
return; "&" makes the program to run in the background).
Note down the number that system prints when you submit a
background process; it denotes the process-id.
Open another window on some other host (say "uranus")
to run the client (type "./CLI" and hit return). 

Type some characters on the window running the client and watch
for the output.
---------------------------------------------------------------
Before leaving, make sure that you KILL your server.
"kill -9 process-id".
---------------------------------------------------------
