Description
1 UDP based Echo Server and Client
Modify the UDPtimed/UDPtime routines to convert them to a simple echo server and client.
2 UDP based Math Server
In this part of the assignment, the goal is to write a UDP-based client and server. The server implements
a simple mathematical calculator. The client sends a message that contains a mathematical operation to be
done. The server performs the necessary computation and replies with the result.
Assume that both operands (op1 and op2) are integers; and that all operators are binary and the operation
is op1 operator op2. The return value is an integer (suitably truncated). The operators to be implemented
are: add, mul, mod, hyp
The hyp operator computes p
op12 +op22
.
Server Client
% ./Mserver 5666
% ./Mclient localhost 5666
Enter command: add 34 56
Received: add 34 56 Answer from server: 90
Enter command: mul 34 56
Received: mul 34 56 Answer from server: 1904
Enter command: mod 22 6
Received: mod 22 6 Answer from server: 4
Enter command: hyp 3 4
Received: hyp 3 4 Answer from server: 5
3 TCP based Simple File Server
In this part of the assignment, the goal is to write a TCP based client and server. The client sends a message
that contains a filename and a number N that denotes the number of bytes requested. Assume that file size
is greater than or equal to N. The server will send the LAST N bytes of the specified file (assume that it is
in its current directory). If the file does not exist, the server sends a special message “SORRY!”.
The client will save the received bytes in a file with name filename1 in the current directory. If the file
does not exist in the server, the client will print the message: “Server says that the file does not exist.”
Assume that the files only contain regular printable text characters.
1
4 What to Submit on IITM Moodle
A single tar.gz file with name ROLLNO-Lab1.tgz containing:
• Source files and Makefile
• A README File that explains how to compile and run the program; whether your programs works
correctly or whether there are any known bugs/errors in your program.
5 Grading
• Echo Server: 8 points
• Math Server: 27 points
• Simple File Server: 50 points
• Viva Voce Exam: 15 points
6 Policies
• This is an INDIVIDUAL assignment. Please refer to first day handout (on Moodle) regarding penalties
for any form of academic dishonesty, plagiarism, etc. There should be no downloaded code.
• Software for checking plagiarism the code will be used.
• The program can be written in C/C++/Java/Python.
• Sample code for writing UDP clients and servers can be found from various sources including Comer’s
text used in the book. In the source code, please acknowledge the sources used.
• Reference URL for C:
https://www.cs.purdue.edu/homes/comer/netbooks.html
• Reference URL for Python (not tested by instructor):
https://www.digitalocean.com/community/tutorials/python-socket-programming-server-client
• Book: Internetworking With TCP/IP Volume III: Client-Server Programming and Applications, Linux/POSIX
Socket Version (with D. Stevens), 2000. 0-13-032071-4
• Book: Internetworking With TCP/IP Volume III: Client-Server Programming and Applications, BSD
Socket Version (with D. Stevens), Second Edition 1996. 0-13-260969-X
2