Foto
Java
fish
hoppsansa
j-uppgift
KTH
Om mig

Fish for ducks v1.0
(centralized server version)

This is the result of the first two parts of my assignment in the course 2G1118 Network Programming in Java at KTH. The task was to develop a client-server File Sharing program (FiSh) to be run over internet and by using Sun Java platform for coding.
   The users uploads a list of files they want to share to a server anywhere on the internet, and the server holds an index of all files shared by all connected users. The users can then use multiple keywords to search for files. On matches, the results are returned and presented to the user who then can choose which files he/she wants to download. The download is then established directly with the users client holding the desired file. On disconnection all shared files of that user is removed from the server.

Hardware Information
The client and server has both been developed and tested on Intel-platforms under Windows XP and Red Hat Linux 7.2 (kernel 2.4.9-31). Java's platform independence should make the program run on many many more platforms that hasn't been tested yet.

Java Software Information
The whole program has been developed by using the editor GNU Emacs 21.1.1 with extended java support by JDEE. The official release of Java 2 platform, Standard Edition v1.4.0 with its tools has been used for development. But the programs are tested and proven compatible with v1.3.1.

Implementation
The server
The server is the central component holding all information about the shared files. As default the server runs at port 47111. New clients connects to the server and gets its own thread with a handler for setup of an TCP/IP-connection. The handler then takes care of retrieving the list of shared files sent by the client, and it processes incomming requests. The server stores each clients files in a vecor, the vector is then added as a post in a global vector used for searching. The search are performed by searching the vectors linear for matches to all keywords specified by user (multiple keyword search). When the server recives a ping from the client, it returns statistics of number of currently shared files and the total size of all shared files. The server also has the ability to ping the client to check if it still is alive, and remove its share if it doesn't answer any more.

The client
A simple and clean GUI is used to communicate with the user. There is a status window showing everything that is done. The first thing the client requires from the user is to select a directory with files to share. By default all files in the subdirectories are shared, but that can be toggled in the sharedialog. The client will refuse connection to the server until the user share more then 0 files totaling more then 0 bytes. After uploading files, the client can use multiple keywords to search for files. The results, if any, is then returned to the client, and the filenames and filesizes are shown in the GUI. The user can then select which file(s) he/she wants for download. Downloads are multithreaded to be able to perform multiple parallell downloads from several other clients. Every download has it owns statuswindow showing average download speed and total progress. All downloads are stored in a subdirectory named Download, realtive to where the program resides. If the filename already exists in the download directory, _<unused number> will be appended to the filename. If the download directory is a subdirectory to the shared directory, each completed download will trigger an update of the share. I would recommend not sharing the Download directory, because it will upload the whole list to the server on each update, and the directory can contain incomplete files. On disconnection the client sends an unshare request to the server and then closes all communication with the server.

Security
When sharing subdirectories there must be a way to tell exactly which file the user want to download, especially if there is several files with the same name. Any absolute or relative way to address the file could be a risc if there are bugs in the code or JVM. To avoid that I have choosen to implement a local vector at the client holding information of all shared files. When sending the list of shared files to the server, only the filename (no path included), the filesize and the index in the vector are sent to the server. Index and filename are then used when another client wants to download a file. The index is used to pick out a record from the local vector, and the filenames are compared. If there is a match, information from the local vector is used to choose file and start the download to the requesting client. Therefor only files in the vector can be downloaded, and the local client is the only one that can access the vector.

Download

  • Compiled: FishClient and FishServer
  • Source code: zip
  • Getting started
    To start the precompiled version of the Client and Server use:

  • java -jar FishServer.jar <optional portnumber>

  • java -jar FishClient.jar


  • Another way to start the client is to double-click on FishClient.jar

    To compile the source code use the included make.bat-file on the Windows-plotforms, else use these commands:
  • javac *.java

  • jar cmf FishClientManifest.mf FishClient.jar FishClient*.class anka.*

  • jar cmf FishServerManifest.mf FishServer.jar FishServer*.class

  • javadoc -d api -version -author *.java
  • Source Code
    Client:

  • FishClient.java

  • FishClientAboutBox.java

  • FishClientDownload.java

  • FishClientDownloadThread.java

  • FishClientGUI.java

  • FishClientServerHandler.java

  • FishClientServerThread.java


  • Server:
  • FishServer.java

  • FishServerHandler.java

  • Documentation

  • API generated by javadoc-tool.

  • Contact information
    Any comments, suggestions and repports of bugs are welcome.
    Send a mail to me at: e98_bbe@e.kth.se

    (c) 2002 Björn Bertilsson e98_bbe@e.kth.se