The protocol is as follows:
- Client connects to server and is prompted to enter an 8 digit ID.
- The ID is sent to the server. The server sends the current date and time to the client.
- The server generates a passcode with the last 4 digits of the ID + seconds of the current time. Say the ID is 11112222 and current time is Mon Feb 6 11:59:33 2023 then the passcode is 2222+33 = 2255
- The client generates the passcode on its end in the same way.
- Client sends its passcode to the server.
- If the passcodes generated by the client and the server match then the server reads a file from its own directory (data.txt) and sends the content to the client.
- The client recieves the data from the server and writes it into a file (recieved_data.txt) in the client directory.
To Run the Program
Split the terminal in 2.
On the server side:
gcc server.c -o server
./server [port number]
On the client side:
gcc client.c -o client
./client [port number]
Note: This program runs on Linux and you must use the same port number when running the client and server.
Helpful Resources
Check out the textbook and videos by prof Jim Kurose to learn about TCP, networking and socket programming: http://gaia.cs.umass.edu/kurose_ross/online_lectures.htm