CMSC 417-0101

PROJECT 1

September 13, 1999

Due: September 20, 10:00pm (via submit)


Introduction

This project introduces the use of threads and networking sockets in Java. (It does not incorporate the automatic testing; that will come later.)

The project consists of two interacting application programs, a server and a client:

You are provided two files: Server.java and Client.java. The following figure represents the layout of the classes:


Assignment

You are required to implement the classes ServerThread and ClientThread described above.
and supply the source in files and ClientThread.java respectively.

Command line

The command line syntax for the Server and Client is given below. The server program takes two command-line arguments: the response_prefix and the server port. The client program also takes two command-line arguments: the name of the host where your server is running and the port number of this host.

java Server <RESPONSE_PREFIX> <server_port>
java Client <server_hostname>  <port>



Useful Classes

Server Socket         http://www.javasoft.com/products/jdk/1.1/docs/api/java.net.ServerSocket.html
Socket                   http://www.javasoft.com/products/jdk/1.1/docs/api/java.net.Server.html
Thread                  http://www.javasoft.com/products/jdk/1.1/docs/api/java.lang.Thread.html
String                    http://www.javasoft.com/products/jdk/1.1/docs/api/java.lang.String.html
InetAddress          http://www.javasoft.com/products/jdk/1.1/docs/api/java.net.InetAddress.html
BufferedReader       http://www.javasoft.com/products/jdk/1.1/docs/api/java.io.BufferedReader.html
PrintWriter           http://www.javasoft.com/products/jdk/1.1/docs/api/java.io.PrintWriter.html



Useful Readings

Custom Networking         http://java.sun.com/docs/books/tutorial/networking/index.html



Notes

Use netstat(1) to see what sockets have been created by your programs (you may have put them in the background; once a program terminates, the sockets it created go away).