FileServer is a multithreaded client-server program that uses TCP/IP connection for establshing a connection between a client and the server. It allows multiple clients to connect to and interact with the server simulataneously. The fileServer is a file storage program that allows the client to upload, fetch and delete files on/from the server. The file can be of any type text, image, video, audio, dmg, etc.
FileServer consist of a multithreaded server that listens for incoming clients on the main thread and processes the client request on a separate pool of threads. This helps the server from not being occupied by the processing of the long running client request. And server will always be available for listening to new client request. Once the server process the client request, the server will generate a response and send it to the client.
and handles each client request on a separate thread.
The client sends a request to the server. And waits for the server response. After the server sends back a response the client displays an approriate message realated to the response to the user.
The client can send the different types of request to the server, which are as following:
- The client can send a request to upload a file on the servre.
- Client can also fetch a file from the server.
- Delete a file from the server.
- Client can also close its connection to the server.
- It can also send a request to shutdown server (In real world scenarios we don't do this :P)
Uploading files on the server
Upload.files.mov
Retrieving files from the server
Retrieve.mov
Deleting files from the server
Delete.mov
Invalid Client Request: For example retrieving/deleting (by file name or file ID) a file from the server that does not exist on the server. Or uploading a file on the server that does not exist on the client machine.
InvalidRequest.mov
Other user actions:
- Invalid user action
- Closing the client
- Shutting down the server
Exit.mov
- Download the project.
- Unzip it.
- Import the project to an IDE like IntelliJ IDEA, Microsoft Visual Studio or Eclipse.
- Build the project.
- Run the main file inside server folder to start the server.
- Run the main file inside client folder to start the client.
- You can also allow multiple instances of the client program to run.
- Open the project directory on terminal/command prompt.
- Move to the server folder and use the javac Main.java command to compile the server program.
- Move to the client folder and use the javac Main.java command to compile the client program.
- Use the java Main command to start the server.
- Use the java Main command to start the client.
Note: You need to have Java on your system to run this project.
Read more about the license here:
Apache License 2.0
Lokesh Bisht