Write a C/UNIX program with the following descriptions:CS476/576
Assignment #5
Due Midnight, Tuesday Nov 20, 2001
NAME
tcpline - A program to reate a chain of processes connected with tcp sockets.SYNOPSIS
tcpline [<Rhost> <Nproc>]DESCRIPTION
The program creates Nproc processes (the default value of Nproc is 2) and each process is connected to its next process with a tcp socket as shown in the next Figure. The odd numbered processes (number 1, 3, 5, ..etc) runs on the localhost (i.e., where the tcpline command started) while the even numbered processes (number 2, 4, 6, ...etc) runs on the Remote host Rhost (the default value of Rhost is the localhost.)
Upon the creation of the the last process, the last process will send a message to the first process via the "tcpline" (the "tcpline" is the (n-1) tcp connections between the n processes) indicating to the user to start providing input (this is similar to what took place in the pipeline of assignment #4) .
Any line typed by the user travels across the "upstream" of the tcpline (an upstream is from the first to the last process) and then travels back through the "downstream" of the tcpline (the downstream is from the last to the first process) and then displayed back to the user via the stdout of the first process. Therefore every line typed be the user is displayed back after a round trip delay over the tcpline. Each process introduces a 1 second delay in the upstream of the tcpline which means that a message will return back to the user after at least N seconds dealy (the additional delay is due of the overhead of sending the message using the tcp protocol).
When the user types CTRL-D, the processes are terminated in the order of their creation, i.e., the 1th process dies first and the Nth process dies last (note this is different from the assignment #4, where processes are terminated in the reverse order of their creation).
Unlike assignment #4, the even numbered processes may run on a remote host and therefore may have no access to the stdout and the stderr (i.e., file descriptors 1 and 2) that are usually associated with TTY and therefore we need to:
To get a feeling and gain
more details about the specification
of this program, execute my
own solution under: /home/cs476/tcpline
See the output file of running
this program twice, one with no argumnets
and another with two arguments:
Examples.
NOTES:
Hints: