java socket programming
File server application
In this assignment, you develop a file server application based on socket programming. The code has two parts: server side and client side. The server, which is a file server, has a number of files available on the hard disk (local folder of the code for instance). The client can either request to receive (download) one of those files or upload a new file to the server.
Client Side:
The client’s graphical user interface (GUI), allows the user to either upload a file to the file server or download a file from the file server. The user decides about the upload or download functionality by providing the file name or address and pressing the download or upload button.
Upload: In the upload mode, the user first chooses the file to be uploaded from the files on its local hard drive. You can implement this in two ways:
1– Your GUI has a “choose file” button. When you click on it, a file browser allows the user to browse through the local hard drive and choose a file.
2– Alternatively, you can have a text field where the user inputs the full address of the file on the local hard drive such as:
“c:myfilestestfile.txt”
After choosing the file or entering the file’s address, the user clicks on the “upload” button and the file will be sent to the server and saved on the server’s local drive.
Download: The user will provide the file name in a text field and click on the download button. The file name can be something like “readme.txt”.
A request with the file name will be sent to the server. If the file exists on the server, it will be transferred to the client and saved on the local hard drive of the client. If the file does not exist on the server, an error message will be instead sent to the client. The client GUI should somehow (either through a pop up window or in a label on the same GUI) show the user an appropriate message saying that “The file requested does not exist”.
Server Side:
The server code does NOT need to have a GUI. It only listens to a specific port and waits for the client’s message. If the client sends an upload request, it will receive the file and save it along with the other files on the file server (a local address). If it receives a download request, it will send the requested file to the client or an appropriate message to inform the client that the file does not exist.
Details and options:
The GUI for the client needs to have:
• A “choose file” button or a “file name” text field in which the client provides the address for the upload function.
• An “upload” button that initiates the file transfer of the chosen file to the server.
• A “file name” text field to provide the file name to be downloaded from the server
• A “download” button that will send the download request to the server
• A label to show the user on the client side, the occurred errors such as “file not found” if the user enters a file name to be uploaded that does not exist, the error message coming from the server that the file requested doesn’t exist, or the server not ready message (if you decide to handle that)