Assignment 0: Palindrome Testing (0 marks)
Due: Friday, January 14, 2022 (4:00pm)Learning Objectives
The purpose of this assignment is to learn about client-server socket programming in C or C++.
Preamble
A palindrome is a word or phrase that is spelled exactly the same forward as backward. For example, "pop", "madam", and "racecar" are palindromes, while "cat", "house", and "banana" are not.
This week only, there is a simple palindrome-checking server running on csx1.cpsc.ucalgary.ca (IP 136.159.5.25) on TCP port 44144. 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, and check whether different words are palindromes or not. This ungraded practice exercise will help you get started with the (very complicated) TCP/IP 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 the C source code for the palindrome-checking server mentioned above. You should be able to compile and run this code yourself, either on your own laptop, or one of the CPSC servers. Your task is to write the code for a client that can talk to this server over a network, using TCP/IP.
Technical Requirements
In this assignment, you will implement your very own client program to talk to the palindrome-checking server. You can do so using either C or C++ (your choice).
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 send candidate words or phrases to the server to be tested to see if they are palindromes. 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-server with some of these examples: "dog", "cat", "eye", "nose", "ABBA", "12321", "banana", "beatles", "racecar", "yellow", "8675309", "submarine", "close the door", "madamImadam", "able was I ere I saw elba", "canyouhearmenow?", "amanaplanacanalpanama", "saippuakivikauppias", "elephantsaretallandstinky", and "alotnotnewIsawasIwentontola". A few of these might actually be palindromes. Who knows?
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 send candidate words or phrases from the client to the server, and print the response (if any) received back from the 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)
If you modify the server to ignore punctuation and capitalization, there might be other phrases that become palindromes (e.g., "Amore, Roma", "A Toyota. Race fast, safe car. A Toyota.")
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!
- Please be polite and follow the application-layer protocol by saying "EXIT" when you are done talking to the server. It likes to know when you are done.
- There is a second palindrome-testing server running on TCP port 12321 just in case somebody crashes the first one. If you think you have accidentally crashed one of the palindrome servers, please let Carey know via email so that he can restart it. Thanks!
- If neither of the servers above are running at all, then please compile and run the server code somewhere yourself, either locally or remotely. Make sure to modify the port number as needed, to avoid conflicts with any other servers that might be running, such as the two mentioned above.