CIS307 - Homeworks 4: Using the Select System Call

Given: November 4, 2008
Due Date: November 24, 2008, by 10pm

In this homework you will write 4 programs to run on 4 nodes. The programs are sender, teeSwitch, and two copies of receiver, receiver1 and receiver2. Sender and the receiver program(s) can be written in either Java or C. teeSwitch must be written in C.

The sender program has the following behavior

	Let foo.txt be a text file with at least 10K characters
	loop
	    open foo.txt
	    open a TCP connection to the teeSwitch program
	    loop
		write foo.txt to the teeSwitch program
	    until you have sent at least 10MB
	    close connection
	    close foo.txt
	    sleep for some time
	forever
The receiver program has the following behavior
	loop
	    accept a TCP connection (from the teeSwitch program)
	    open a file moo.txt for writing with truncation
	    while the connection is open
		read from the sonnection and write to file
	    close the file
	    close the connection
	forever
The teeSwitch program has the following behavior
	establish a TCP listening socket
	loop
	    accept a TCP connection from the sender
	    connect to the receivers
	    while the connection with the sender is open
		read from the sender and write to the receivers
	    print statistics
	    close the connections
	forever
The teeSwitch uses the select system call to maximise the concurrency between reads and writes. Since some buffering will be required, try to avoid as much as possible delays and copy operations. However, do not use for buffering more than 1MB.

We want to collect and print the following statistics

In the readme text file please describe and justify your design decisions

Submit the homework to the blackboard dropbox.