2G1118: Network Programming in Java
This assigment was developed on a PC PII 866 MHz Intel Pentium, 512MB RAM, 68 GB disk, W2K.
Software used:
-jdk1.3
-Borland JBuilder 4 Foundation
-Forte for java release 2.0
Assignment 1 -A centralized filename sharing system
Focus: client-server application
Goal: to build a basic client that can connect to a server, send it a
list of shared files and disconnect, and a basic server that manages a directory
of shared files.
Assignment 2 -FISH with a centralized server
Focus: file searching and retrieving
Goal: to add file searching and retrieving to the previous system.
Assignment 3 -FISH using multicasting
Focus: multicasting
Goal: to re-design the client to use multicast and a distributed search
system.
The assignment consists of a Client and a Server application.
One or more Clients connect to the Server and tells the Server wich files it
shares. It sends a "Connect" request along with the filenames as a
String separated with a token.
The Server saves all names of shared files, with a host and port associated
with it, in an hashtable of Vectors. So that if two Clients shares a file with
the same name it is hashed into the same Vector.
Any Client can send a search request for a file (must be fully correct name) to the Server. The Server will send back the results or "file not found" if no matches are found.
If a Client choose to download a file, it will send a request directly to the other Client along with a port number to wich to send the requested file.
When a Client disconnects from the Server the shared hashtable is updated.
In case of a Client crash, the Server "pings" each Client systematicly. If it gets no respons from a Client, it updates the hashtable.
All communications between Client-Server, Client-Client, occurs as Strings wich can be parsed into useful information. The communication is established via sockets.
The Server runs a thread wich listens to incomming communication, depending on the first word in the incomming String, the Server performes different tasks (connecting Cliens, disconnecting them, searching for a file..etc.).
Each Client also runs a thread wich responds to "pings" from the Server and listens to requests for downloads from other Clients.
When a Client wants to download a file from the list of search results sent by the Server, it creates a new socket, and sends a request to the other Client for the file, including the portnumber to the socket. The Client who has the file, sends it back to the requesting Clients socket.
The Client comes with a GUI that is simple and straight forward to use.
To be able to connect, the Server, Port, Shared Files and Save Directory fields
has to be filled in.

The Server and Port field comes with default values.
The path to the Shared and Saved directories chooses with the Change button:

The GUI comes with a System Message area, wich will keep the user updated in possible errors or the progress of a downloading file.
This assigment consist of a singel MulticastClient wich acts as both a Client
and a Server.
Every Client connects to a multicast group to be able to communicate with other
Clients.
Instead of sending a list to a server with information of its shared files, the Client initializes a Vector with the shared files names in it.
Every connected Client runs a thread, as the Server did in assignment 1-2, to listens for incomming communication. In this assignmnet multicast (broadcast) is used so the thread listens to an UDP-socket instead of a normal (TCP) socket. Since UDP package is uset in multicasts. When a search question is recieved, the Client checks its shared Vector for a match, if one is found, it waits for a randomly small time (to awoid flooding), before it sends an answer back, directly to the questioner.
Before sending the reply the Client starts a new thread and opens a new UDP socket with an timeout limit, to be able to recieve download requests for that specific file. In case of a request, the file is sent (as in assignment 1-2), to the requester via an TCP socket.
When a Client wants to search for a file, it starts a thread, opens a UDP socket and sends out a multicast package with information about the file and wich port to reply to. A max number of search results (10) are displayed. There is also a timelimit to the reply socket.
When the results have been displayed and the user chooses to make a download, a new thread is started, a TCP socket is created and an UDP message is sent back to the Client wich corresponds to the choosen file.
The GUI is used as in assignment 1-2, with exception that the Server field should contain an multicast address.