CS 580 Client-Server Programming

Spring Semester, 2007

Assignment 2

Assignment Index

© 2007, All Rights Reserved, SDSU & Roger Whitney

 San Diego State University -- This page last updated 2/5/07

Assignment 2

You will be writing a small client-server system. The system is motivated by American Idol.

The protocol for the system is as follows. The client can send three commands to the server: "add", "vote", and "result". The format for the add command is:

    add<sp><name>;

where "<sp>" represents the space character and <name> is any string that does not contain ";". Names are not case sensitive. Note that the characters < and > are used to indicate special  characters and are not part of the command.

The server's response is either:

    success;

or

    error<sp><message>;

where <message> is any string that does not contain ";" and is text explaining the error. A name can only be added once. If the name already has been added an error message is returned.

The format for the vote command is:

    vote<sp><name>;<yesOrNo>;

Where <yesOrNo> is either

    yes

or

    no

With 'yes' indicating a vote for the given name and 'no' a vote for the given name. The server responses with either:

    success;

or

    error<sp><message>;

The format for the result command is:

    result<sp><name>;

If there is no error the server returns:

    name:<name>;yes:<n>;no:<n>;

where <n> indicates the ASCII representation of an integer indicating the number of yes(no) votes for the given name. If there is any error, for example the name has not been added, an error message is returned of the form:

    error<sp><message>;

The server closes the connection after sending the response.

If the server receives any request not described above it responses with

    error<sp>invalid<sp>command;

and then closes the connection.

Sample Interactions

Client Request

Server Response

add cat;

success;

result cat;

name:cat;yes:0;no:0;

vote cat;yes;

success;

result cat;

name:cat;yes:1;no:0;

Note the reference server also implement the command "list". The format of the command is:

    list;

The server response is:

    <name1>;<name2>;...;<nameN>;

That is all names added to the server are returned followed by a ";".

The Assignment

Part 1 Write a client that implements the protocol. The client does not have to be GUI based.

Part 2. Write a server for the protocol that supports logging. Log each request. Also read setting for your server from command line and a configuration file.

Part 3. Use threads to allow your server to handle more than one request at a time.

Part 4. Modify your server to use a database to store the count and data information associated with each url.

Due Dates

Part 1. Feb. 13

Part 2. Feb 20

Part 3. Feb 27

Part 4. March 6

Just for Fun

1. Write a port scanner. That is a program that given a machine will return a list of ports that are open (that is have servers listening on that port) on the machine. If you know TCP/IP well write the port scanner so that the remote machine will not log the access to its ports.