CPSC 441: Computer Networks

Winter 2022

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:

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