Homework 4 -- Writing a client or server

Preparation

Create a drop-off directory within your Computer Science home directory by typing the following commands:

The task

A server is running at port 8800 on enka.cs.unca.edu. The original idea was that this server, when sent the right input, would produce output somewhat similar to the prose of that classic book Brown Bear, Brown Bear, What Do You See?, written by Bill Martin, Jr. and illustrated by Eric Carle. However, I'm not sure that fits with copyright laws, so I'll try something different.

The server "remembers" one animal, which we'll call the old animal. Each client connection provides as input a new animal, which is sent through the socket as a string terminated by a carriage return. The server then prints, through the socket, two lines of output similar to the following

and then replaces the old animal with the new animal.

Right now the server is running on port 8800 of enka.cs.unca.edu. If you telnet to port 8800 of enka and type a line of text, which should be a color followed by an animal such as "pink squirrel", you should receive a response from the server. By the way, you really ought to do this twice so that you can see that animals really are remembered.

The assignment

This is a 30 point assignment that can be completed at different levels. Your completed assignment should be stored in the directory ~/csci/343/home04 that you created above.

The C/D level

This is really a minor modification of homework 1. You write a client program that sends a line to the server and prints its response. Your solution must be totally your own work.

If you choose this level, store your program in home04x.c.

The B/C point level

At this level, you write a client program that prompts the person running it for lines of input. Each line of input is sent to the server. Then the server's response is read and printed to the terminal.

You can do this assignment in groups of up to two, if both you and your partner keep a "diary" as explained below.

Note that since the server will only process one line of input for each connection, you'll have to create a new socket for each line you send to the server.

If you choose this level, store your program in home04y.c or some other appropriately named file for non-C programs.

The A/B level

At this level you must implement a server for the problem. You may do this in groups of three, as long as all members of the group keep a diary of their work.

You'll have to make up a unique port number that won't conflict with those used by others. If you chose a random number above 10,000 you should be safe.

If you choose this level, store your program in home04z.c or some similarly named file.

Diaries and groups

One of the difficulty in grading group projects is determining the contributions of each team member. If you work in a group, you must complete a diary that documents the time you individually spent on the project. You may store your diary in a protected file in the drop-off directory, or you may email it to me. Your diary is confidential. It is only for you and me, not for your teammates.

Some effort will be made to assign grades based on individual contribution. This will by necessity favor individual projects over group projects. However, don't attempt an individual project if you expect to depend on the work of another! Just work with the other person in a group.

Asking for help

You are not allowed to show (or email) your code to someone who is not a member of your group without the explicit permission of the instructor. You are also not allowed to review the code of others without their explicit permission.

Checking the server

The server running on enka has been written to log its output at the following URL.

You should see log entries whenever a client connects to the server and whenever the server reads an input line from the client.

Due dates and turning it in

This assignment is due at noon on Friday, October 29. No late assignments will be accepted.


Back to the CSCI 363 homework page
Back to the CSCI 363 home page