V22.0480-002 Special Topics: Networks

Homework 2: Create a networking application using the socket interface to implement a "character count" service over TCP.

For this assignment, you must write the client and server code to implement a character count service over TCP. The following describes the application, session, and presentation layers.

Application Layer:

The client side of the application connects to the server. The client then reads characters from the terminal until it reads a new-line character. The client sends all characters entered to the server (but the client does not send the new-line character).

The server reads the characters, counts the characters, and returns the count back to the client. The process repeats until the client sends "--" .

Session Layer:

The NULL character serves as the session-layer ending of each string of characters (the NULL character is not included in the total count of characters). When the client wants to end all communication, it sends two minus signs, followed by a NULL character.

Presentation Layer:

The client sends ASCII characters to the server. The server returns a NULL-terminated ASCII string containing count. So, if the client sends 102 characters, the server would return the NULL-terminated ASCII string "102".

Here is an example output:

$ rcount sparky
How long is this string?????

The address of your service will have a port number that corresponds to the last 5 digits of your student ID.

What you must turn in:

The C code that implements the client-side of the application.
The C code that implements the server-side of the application.

Due date: Monday, October 22