CIT 597 Assignment 4: Simple file server and client
Fall 2005, David Matuszek

Purposes of this assignment:

General idea of the assignment:

Write a server program which, when requested for a file, sends that file.

Write a client program that can request files and save them.


Write a server to send files upon request, and a client to request them. Both programs will be Java applications (no HTML or JavaScript involved here).

For a simple example of a client and a server, see and The server simply gets a text string from the client, reverses it, and sends it back. These examples are from Advanced Internet Applications with Java (2nd edition) by Art Gittleman.

ReverseClient expects an IP address as its single parameter to main; the parameter may be localhost to say "this computer".

The server will start listening on a specific port (use port 8122).

The client will initiate communications on that same port. For communication to occur, the server must start up before the client.

The GUI should have (at least) these elements:

You can use other GUI elements as you choose, so long as your interface is simple and obvious.

The program should not quit after downloading a single file. You can have a Quit button if you like, or you can quit the program by simply closing the window.

You do not need to write a multithreaded server.

If you have only used the AWT, not Swing, I have a program and some examples that should greatly ease the transition for you. Download and unzip it in a directory of your choice. This will unzip into two files, SwingExamples.jar and You must keep these files together in the same directory. Run the program by double-clicking on SwingExamples.jar.

Danger Will Robinson Danger!!!

As described, this very simple file server has no security features whatsoever. When it is running, anyone can download any file from your computer.

Don't think that the use of an unusual port number provides any safety. It can be easily found by a port scanner.

For some very limited security, the client should send some kind of password, which the server can check, and ignore any request that does not contain this password. The password can be hard-wired into both programs; the user does not need to know that it is there.

However, for maximum security, avoid running your server while connected to the internet.

Due date:

Wednesday, October 12, before midnight. Zip and turn in all relevant files via Blackboard.