Distributed Systems Lab/06 | |||||||
|
Lab 1 / Simple Sockets File Transfer ClientIntroduction
Most interprocess communication uses the client server model. These terms
refer to the two processes which will be communicating with each other. One of
the two processes, the client, connects to the other process, the server,
typically to make a request for information. A good analogy is a person who
makes a phone call to another person.
Detailed Description Your objective is to develop a simple sockets-based text file transfer client in Java (version 1.5). This client can connect to a file server and enables the user to look for ASCII TEXT files and download them (i.e., you do not need to worry about transfering binary files such as images and programs). The functionality of your file transfer client should be coded into the class Client, which is stored in the file Client.java. The class should be a stand-alone program that will be directly invoked by java. Therefore, it must contain a static main() function. Your program is supposed to take exactly two command-line arguments. If more or less than two command-line arguments are passed to your program, or some error happens (e.g., a host ist not found) you have to exit immediately with exit code 1 (i.e., System.exit(1)). In all other cases, your program should exit with exit code 0. The synopsis of the program is as follows: java Client <server> <port> where
When your program is invoked with two arguments, it should first connect to the file transfer server. Then, your client should read commands from the standard input (System.in in Java). Your interactive client should understand and process the following commands (note that all commands are case-sensitive... i.e., LS is an unknown command):
Note that the our server uses the UNIX file separator "/" in file and directory names (e.g., "ls /funny-stuff"). The file transfer server uses a simple protocol to communicate with its clients. Here is the protocol description (to give you some "hands-on" experience reading protocol descriptions, we made it look like a typical protocol specification).
After your client connects to the server, it should print:
Here is an input file that you can use for testing. Download this file and
invoke your client as follows:
If you are testing interactively, here is the output you should see on the
display: In case of any errors (null pointer exception, host not found, etc.), terminate your program with exit code 1. Hints for Solving the Lab
Deliverables To submit your solution to us, you need to follow these steps:
Deadline You need to submit your solution until November the 2nd, 17:59. Closing words Have fun ;-) Last Modified: Fre Nov 10 15:32:01 CET 2006 |
Distributed Systems Group, Technical University of Vienna, Argentinierstrasse 8 / 184-1, 1040 Vienna, Austria, www.infosys.tuwien.ac.at |