Project 2 -- Sockets, encryption, and client/server


We going to write a simple fortune cookie server. That is, you need to write two pieces of software: a client that sends requests for a fortune cookie to display, and a server to provide the fortunes upon request. Note that you should pick a partner and work in pairs on this project.


Communications requirements

There are a few critical requirements for the communication between the client and server:

The server and client should be invoked, respectively, like so:

remus:~> java FortuneServer 2468
romulus:~> java FortuneClient remus 2468

That is, the server should be provided a port number on which to listen. Similarly, the client should be provided both the server's hostname and the port number. Your group should randomly select a single port number between 10,000 and 65,636 and use it consistently. Be aware of the small possibility that two groups will pick the same value, and thus interfere with one another.

Your client and server interaction should follow a specific sequence of steps:

  1. Establish a connection using sockets.
  2. The client sends the server its public key.
  3. The server encrypts a fortune using that public key and transmits the encrypted fortune.
  4. The client decrypts the fortune and displays it to its user.
  5. Disconnect.

Java classes you will need

Communication via sockets requires use of some special Java classes.

To find out more about these classes, see the Java 1.5 API documentation.


Submitting your work

Submit your Client.java, Server.java, and any other supporting source code like so:

cs29-submit project-2 *.java

This project is due at 5:00 pm on Wednesday, 2004-December-22.

Scott F. Kaplan
Last modified: Sun Dec 5 12:47:43 EST 2004