Exercise 2: Building Reliable File Transfer –
Part 1
In this C exercise you will implement reliable file transfer between a
client and a server (from the client to the server) using TCP (in part 1) and
using UDP (in part 2).
Introduction:
This exercise is composed of two parts.
In the first part, you will implement a client/server which transfer files from
the client to the server using TCP. In the second part, we will implement the
same file transfer using UDP.
Synopsis:
For running the server:
srftp server-port
For running the client:
crftp
server-port server-hostname filename-to-transfer
server-port:
is the port used by the server
server-hostname: is the host name
of the server
filename-to-transfer: is the name of the file to transfer from
the client to the server, it must reside in the same directory as the client
was executed from.
It will be copied to the same directory as the server was
executed from with the same name as it had on the client. If such a file
already exists on the server then it should be overwritten.
Basic requirements
of the server design:
- The server should handle
clients using a single process, using the select() system call.
- Remember that on the next
exercise, we will change the underlying protocol to UDP so try to think
about future implementation as well.
Basic requirements
of the client design:
- The client initiates the file
transfer
Testing Your Program:
- Run the server on one machine. Run the client and send a
file to the server. Use “diff” command to verify the file was
created properly, and has the same size.
Error Handling:
- You can assume the input
parameters are correct.
- In case of an unrecoverable
error (e.g., if the program can't open a socket), the program must
exit(1) and write an error to STDERR. In case of success the client
program should return 0.
Useful system calls:
socket, bind, connect, listen, accept, send, recv, select, close, inet_addr, htons, ntohs, gethostbyname
What to submit
- The
files srftp.c and crftp.c.
- A Makefile which compiles the executables
ctftp and srftp
(should work on the system Linux computers like inferno)
- A
README
- Example Makefile is found here
- Example c files : crftp.c srftp.c
- Don't forget to check your tar using the checkme_ex2a.sh script.