IUNP Programming Assignment 1

Should be done by Monday

This programming assignment is meant to prepare you for assignment 2. By implementing the program specified in this assignment, you would get familiar with the Unix network programming API. The assignment is to be done in groups of size 2 at the most. (I would prefer you doing this alone.) You are responsible for finding your partner. Please carefully read the example codes I've given, and build your program on top of the examples. Doing so is not absolutely required, but it will save you a lot of time.

The program is to be written in C or C++ under a Unix platform such as Linux, SunOS, Solaris, or FreeBSD. The catch is that, you have to make sure your program compiles under Solaris. There should not be any problem working under different Unix platforms, if you use the Makefile as in the examples I've provided.

The program to be written is called thechoer (or your favourite name), whose features are described below.

		thechoer <tcp-port> <udp-port>
		IP address         hostname           upd port      tcp port
		192.168.0.3 (funny.cse.buffalo.edu)     4892           43444
		connect 192.168.0.3 99999

the two sides then report that the connection is indeed established.

		conn. ID |      IP       |     hostname         | local port | remote port
		---------------------------------------------------------------------------------
		   1     | 192.168.0.1   | abc.cse.buffalo.edu  | 1234       | 1235
		   2     | 192.168.0.2   | def.cse.buffalo.edu  | 1453       | 98234
		   3     | 192.168.0.3   | ghi.cse.buffalo.edu  | 1233       | 09823
		   4     | 192.168.0.4   | xyz.cse.buffalo.edu  | 1235       | 0823
		send 3 Oh! This assignment is a piece of cake.
		got Conn. request from 192.168.0.2, child 19534 handling it.
		echoing "message"
			to: IP   = <ip-address>
		        type = tcp

		        PID  = <my-pid>

here, "message" is the message that it is echoing, <ip-address> is the ip address of the other end, and <my-pid> is the child's process id.

		echoing "message"
			to: IP   = <ip-address>
		        type = udp
		        PID  = <my-pid>

		got echoed message "message"
			from: IP   = <ip-address>
		          type = udp (or tcp)
		          PID  = <peer-pid>

the meaning of each field should be clear.