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.
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 |
For simplicity, only text files can be got using this server.
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.
This assignment (and the next one) must be done individually.
The assignment is due in the class of Week 13, Tuesday May 20.