ICT214 O/O Design and Programming

Assignment Two
Semester 1, 2008

Introduction

This assignment is the second of two, which are linked: this assignment extends and adds to the first one.

Client server applications form the basis for nearly all network applications. In this style of programming one part of the application runs as a server on one computer while the other part runs as a client on another computer. A common application is for file transfer, where a client is able to discover files on a server and copy them from the server to the client's computer. This assignment will do a simple form of a file transfer application.

Details

You will need to alter the console-based application of assignment one into a GUI application using Swing classes. The application will repsond to user selection of items displayed and send appropriate commands to a server. It will read responses from the server and display them to the user.

For this assignment the GUI client needs to be written and also the server. The server can be a command-line application and does not need a GUI.

The server will run on port 2008. A client will need to be supplied with the server's address (e.g. by a command line argument). The client will then connect to the server and start sending commands and reading responses.

The client will send commands as a single line of text. The server will reply with one or more lines of text or a stream of bytes. Each line from the client will be terminated with a CR-LF pair. All messages will be encoded using the ASCII character set. The commands sent by the client will be

Command Meaning
GETCWD Get current working directory
CHDIR <directory> Change current working directory
LIST List files in current directory
GET <file> Get a text file's contents
QUIT End this session

The responses sent by the server will be

Client Command Response
GETCWD One line of text containing the directory name
CHDIR <directory> SUCCESS or FAIL
LIST One line with a number saying how many files will be listed, followed by each filename, one per line
GET <file> One line with a number saying how many bytes are in the file and then a byte stream of that length. If there is an error in accessing the file, then there is only one line returned, containing "-1"
QUIT No response, the connection is closed
Any other requests will get a return of "ERROR". Each line of text will be terminated by a CR-LF pair. Each text message will be encoded in the ASCII character set.

For simplicity, only text files can be got using this server.

Deliverables

You should hand in the following

You will be asked to demonstrate your system. This will be in the tutorial of the week of submission.

Group size

This assignment (and the next one) must be done individually.

Due date

The assignment is due in the class of Week 13, Tuesday May 20.


Jan Newmarch (http://jan.newmarch.name)
jan@newmarch.name
Last modified: Wed Apr 23 09:35:56 EST 2008
Copyright ©Jan Newmarch