Assignment 0: Client-Server Testing (0 marks)
Due: Friday, September 17, 2021 (11:59pm)Learning Objectives
The purpose of this assignment is to learn about client-server socket programming.
Preamble
On the Internet, there is a simple CPSC 441 test server running on csx1.cpsc.ucalgary.ca (IP 136.159.5.25) on TCP port 44101. You can verify its existence using the telnet command as demonstrated in class. Your goal in this warm-up assignment is to write a simple client-side program that can talk to this server using a TCP socket. This practice exercise will help you get started with the (much more complicated) socket programming required for Assignment 1.
Background
Most network applications are written using a client-server paradigm. The server is a special entity that runs forever, listening for clients that make requests for its specific service. Clients are ordinary users (or computers) who send requests to the server asking for service. Here is an example of the C code for the CPSC 441 test server. Your task is to write the code for a client that can talk to this server using TCP.
Technical Requirements
In this assignment, you will implement your very own client program to talk to the CPSC 441 test server. You can do so using either C or C++ (perhaps both!).
There are three main pieces of functionality needed in your client. First, it needs to establish a TCP connection to talk to the server. Second, it needs to exchange one or more commands with the server, presumably in a loop to support client-server interaction from the user. Finally, once the client is all done, it needs to gracefully close the TCP connection that it was using.
When you are finished, please show your solution to your TA in your tutorial section. You do NOT need to upload anything into D2L for this one.
Testing
You can test your client using the following commands:
- HELLO: a polite application-level opening handshake between client and server;
- HELP: a query to see what basic commands the server supports;
- COUNT: a query to see how busy the CPSC 441 test server has been;
- INFO: a query to show what IP address and port the client is using;
- BYE: a polite application-level closing handshake between client and server.
Good luck, and have fun!
Grading Rubric
The grading scheme for the assignment is as follows:
- 0 marks for the design and implementation of a functional client program that can handle simple commands between client and server.
- 0 marks for a suitable demonstration of your client to your TA in your tutorial section (or to your professor) at a mutually convenient time.
Bonus (optional, 0 marks)
There might be a few other commands that the server supports, but these are undocumented. If you find some, make sure to mention this during your demo.
Tips
- This is intended to be a very easy assignment, so please feel free to do it on your own time whenever convenient. You will likely need 1-2 days of thinking/coding/debugging time to get it fully working.
- If you have never done socket programming in C/C++ before, you should make sure to get to your CPSC 441 tutorials on this topic. Don't miss them!
- There is a second CPSC 441 test server running on TCP port 44102, just in case somebody crashes the first one. If you think you have accidentally crashed one of the servers, please let Carey know via email so that he can restart it. Thanks!
- If no CPSC 441 test server is running at all, then your next best option is to compile and run the server code somewhere yourself, either locally or remotely. Make sure to revise the IP address and port as needed (e.g., if testing over the loopback interface).