# File Transfer using Java Socket Programming

This project is a basic implementation of a file transfer protocol using a server-client architecture in Java. The client can connect to the server, make a request to the server for a particular file(i.e. file1, file2 and file3). As response, the server process the request and sends the file according to the client's need. Note that multiple client can access the network which implies we have implemented multi-client server in our implementation.  

## Features

This project uses a server-client architecture and implements the following features:
- A Server class that listens for incoming client connections and creates a new thread for each connected client
- A ClientHandler class that handles each client connection, reads request from the client, and sends the file according to the client(s) request
- A Client class that connects to the server, sends the message to the server which file a client wants, and receives the file from it requests for from the server

## Protocol Develoved

“File Transfer Protocol”(FTP), a simple client-server protocol for the file tranfer system can be defined as follows:

- The client establishes a connection to the server using the server's IP address and port number.
- The client sends a file request to the server. For example, the server is containing 3 files such as file1, file2 and file3. Now, those files are mapped by 1,2 and 3 respectively(i.e. file1-->1, file2-->2, file3-->3). If the client encounter a 4, it will be exited from the server and for any other input the server will show the client that the input is invalid.
-The server receives the file request and checks the provided request and matches whether that file is available or not. If the file is available it sends the file to the client
- The client at last recieves a file if it requests for a valid/available file.
- The client can log out by encountering a "4" to the server and close the connection.

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

### Prerequisites

- Java 8 or higher
- A text editor or an IDE to run and edit the code

### Installing

1. Clone or download the repository to your local machine.
2. Open the project in your text editor or IDE.
3. Make sure that the path of 'file1.txt', 'file2.txt', 'file3.txt' files are correct in the Server.java file.
4. Run the Server.java file, it will start the server and will wait for a client to connect.
5. Run the Client.java file, it will prompt for the server's IP address, enter the IP address and press enter.
6. The client will be connected to the server and will display a menu for the user to perform various operations.

## Built With

- Java 8

## Authors

- [Abdullah Ibne Hanif Arean](https://github.com/abdullaharean) 
- [Mehadi Hasan Santo](https://github.com/Mehadi-Hasan-Santo))

## Acknowledgment
- This project was created for educational purposes, and it is a basic implementation of a file transfer system using a server-client architecture in Java.

## Note 
- This project is intended to be used for educational and testing purposes only.

## Conclusion
This is a basic File Transfer Protocol that demonstrates the use of sockets and threads in Java. It can be easily enhanced with additional features according to user requirements.
