[Solved] File Transfer Protocol Program #4

$25

File Name: File_Transfer_Protocol_Program__4.zip
File Size: 310.86 KB

SKU: [Solved] File Transfer Protocol Program #4 Category: Tag:
5/5 - (1 vote)

Program Description

You will write the Server and the Client programs that run a simplified File Transfer Protocol for transferring files. The Server must be able to handle multiple clients simultaneously and listen on port 5521 (control connection) for file transfer requests. Once a request is accepted, the Server opens another port (data connection) for the Client to establish the connection dedicated for file transfer (you can use 5520 or any port numbers between 5500-5540.) The data connection should be closed after the file transfer is done. However, the control connection must remain connected until the Client is disconnected. Each Client should be handled with a separate thread.

The Protocol

The simplified FTP supports only two commands: GET [filename] and PUT [filename]. A GET command transfers a file from the Server to the Client, and a PUT command transfers the file from the Client to the Server. The Client will initiate the connection and send either a GET or PUT command. The sequence of interactions between the Server and Client are summarized as follows.

  1. Client: connect to the Server through the control connection 5521.
  2. Server: accept the connection and send the list of files available for download to the Client.
  3. Client: the UI displays the list of files from the Server. The Client sends either GET or PUT command as a request to download/upload the selected file, one at a time.
  4. Server: receive the request, open a data connection dedicated to the file transfer, and send the port number to the Client. Close the data connection once the file transfer is done.
  5. Client: use the specified port number to contact the Server for the file transfer, and close the data connection once the file transfer is done. Client UI must refresh and show the updated list of files. The Client can send another request through the control connection, or disconnect from the Server.

The following screen shots are sample Client UI with sample runs and the sample Server system output. You must use a JList to list the remote files in the folder Files from the Server, and a JList to list the local files from the Clients current folder.

Program Requirement

  1. The Servers system output must show the Server is currently running, and display all file transfer activities. You must try-catch everything and display appropriate error messages identifying the specific exception. The Server must not crash under any situations.
  2. The Server must include 2 classes: FTPServer class and FTPThread You must use JFrame for the Client program. All files must be sent in 1024-byte chunks. Follow the instructions below.
  3. You must schedule a demo by sending me an email. After the demo, you must zip all files for Program 4 and submit the zip file to the Program 4 Dropbox on D2L by the due date.

v Server Program

FTPServer class will be multi-threaded, where the processing of each incoming request will take place inside a separate thread of execution (FTPThread). You must have a run() method in FTPServer class.

FTPThread class implements a proprietary File Transfer Protocol that handles file transfers to/from the

Clients.

This class extends Java Thread class and you must implement the run() method that handles the file transfer. You must implement and use the following private methods.

  • listFiles() retrieve all file names (excluding folders) from the folder Files and send a list of file names with a single String instance to the Client socket. Here are some useful methods.

File dir = new File(Files); // create a new instance of File class and set the pathname File [] files = dir.listFiles(); // get the list of all files files[i].isFile() // returns true if files[i] is a file NOT a folder files[i].getName() //returns the file name as a String

  • sendFile(String filename) send the file filename thru the data connection. The file path will be Files\ + filename, if the folder Files contains the file. You must use double back-slash because a single back-slash identifies a control character next to it.
  • getFile(String filename) receive the file filename thru the data connection. The file path will be Files\ + filename, if the file is to be stored in the folder Files.

v Client Program

You must use JFrame and include the following components.

  • JTextField for host IP/name and port number, and a JButton to connect/disconnect to/from the Server.
  • JList for displaying the remote files on the Server and the local files on the Client.
  • JButton for sending the GET or PUT command.
  • JTextArea for displaying messages and the interactions between Client/Server.

When you bring up your Client, the local files must be automatically loaded to the JList. When the connect button is clicked, the remote files must be displayed on the JList. You must implement the following private methods.

  • listRemoteFiles() read the String sent from the Server, and use StringTokenizer to decompose the file names. Create an instance of Vector class and add all file names to the list. To export the names from the Vector to the JList, use .setListData(Vector v)
  • listLocalFiles() retrieve filenames from the local folder and list all files on the JList. Use an instance of Vector class to manage the list.
  • sendFile(String filename) send the file filename thru the data connection.
  • getFile(String filename) receive the file filename thru the data connection.

Program Grading your grade will be posted within 5 business days after the due date.

Exceptions/Violations Each Offense Max Off
Program not running 20 20
Failed to transfer files between Client and Server 20 20
Failed to handle multiple connections 5 5
Improper list of files of Server/Client on UI 3 6
File transfer activities are not displayed properly 2 6
Exceptions not caught and handled 2 6

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] File Transfer Protocol Program #4[Solved] File Transfer Protocol Program #4
$25