< CSC 469/569 Homework 4

Homework 4 : Networked GUI Applications Using Binary Protocols

This project modifies the Networked Map Server and Client of Homework 2. The modifications switch to a binary protocol, and we replace the command-line client with a GUI client.

The protocol commands sent by the client to the server are represented by non-negative integers that are the ordinals of the enumeration constants of the following enumeration type

/**
 * Enumeration type defines operations for the binary protocol.
 * @author gcm
 */
enum Op
{   
   help,  get, put, values, keyset, mappings, bye, not_found;
   
   private static final List opValues = Arrays.asList(Op.values());
   public static Op get(int ord) { return opValues.get(ord);}   
}
    

The one exception among these commands is the not_found command. This is never sent by the client. It is returned by the server when the client sends the get command for a key that is not in the map.

All commands sent by the client start with an integer code, optionally followed by parameters. All server responses begin with the same integer code sent by the client, followed by data that is being returned by the server as part of the response. The exception to this is the get command when a non-existing key is requested. In this case, the server returns a response beginning with the code not_found.

Here is a complete description of the exchange betwween the client and the server. The server response to each client message is shown.

  1. help: the server returns the code for help followed by a string that lists all commands available to the client. Each command is terminated by a new line.
  2. put string int: the server returns the code for put followed by the string Ok to indicate to the client that the command was understood and carried out. The server will store the string-integer mapping in the map.
  3. get string: the server uses the string as a key into the map and retrieves the corresponding integer value. If the key is found, the server returns the code for get followed by the associated integer value. Otherwise the server returns the key for not_found followed by the string Key not found.
  4. values: the server response consists of the code for values followed by the string form of the values collection of the map.
  5. keyset: the server response consists of the code for keyset followed by the string form of the key set of the map.
  6. mappings: the server response consists of the code for mappings followed by the string form of the mappings of the map.
  7. bye: the server response consists of the code for bye followed by the string See you later.

The server should be written so that it is multithreaded, and automatically sends a welcome message to the client as soon as a client connects.

A client shell with the graphical user interface already implemented is provided for you. Here are a few screen shots showing the client in action. When you start the program, a dialog box pops up to allow the user to enter the IP address of the server:

Once the user enters the server's IP address, the main window of the application appears, and the welcome message sent by the server shows up in the server response text area.

The next screen shot shows the UI after a put command has been sent to the server.

The following screen shot shows the UI after a second put coommand.

Here is what the UI looks like after a get command to retrieve the value associated with the string North Central College.

Next is a screen shot after a sequence of commands to display the values set [2014, 4]; to get the value associated with North Central College, and to get the key set.

Here is another screen shot after additional protocol commands.

What to Hand in, and Due date.

Turn in a zip folder containing the Netbeans projects for both the server and the client. This is due Monday of week 8.

Additional Downloads

You can look at the example of the binary protocol server and client that we discussed in lecture on Thursday of week 6. The client uses the command line to interact with the server.