Pi-Share is a distributed file sharing system developed for CS 341. It allows clients to upload, download, list, and delete files from a central server, with support for sub-servers to distribute load and storage. The system uses TCP sockets and supports redirection for scalability.
To compile the client and server, navigate to the project directory and run the following command:
makeThis will generate two executables: client and server.
Before running the client, you need to start the server. In the terminal, execute:
./server <port>The server will start and listen for incoming connections on the specified port.
./client <main_server_ip>:<main_server_port> ADD_SERVERThis will send information about your sub-server to the main server and start the sub-server on your computer.
Once the server is running, open another terminal window and execute:
./client <server_ip>:<server_port> <method> <remote_file> <local_file>If more information is required, run the client without any arguments for usage help.
Replace server_ip and server_port with the main server's information.
./server 9000This will create a Pi-Share directory (if it doesn't exist) and listen for connections on port 9000.
Suppose you have a file called hello.txt in your current directory.
./client 127.0.0.1:9000 PUT hello.txt hello.txt- This uploads
hello.txtfrom your local machine to the server, storing it ashello.txton the server.
./client 127.0.0.1:9000 LIST- This will print the list of files currently available on the server.
./client 127.0.0.1:9000 GET hello.txt downloaded.txt- This downloads
hello.txtfrom the server and saves it asdownloaded.txton your local machine.
./client 127.0.0.1:9000 DELETE hello.txt- This deletes
hello.txtfrom the server.
Suppose you want to add a sub-server running on the same machine (using port 8080):
./client 127.0.0.1:9000 ADD_SERVER- This will register your machine as a sub-server with the main server and start a new server instance on port 8080.
Alternatively, if you want to start a sub-server on another computer, find the ip address of the current computer and then run the following command to add it.
./client <current computer ip>:9000 ADD_SERVERNote:
- All files are stored in the
Pi-Sharedirectory on the server. - Replace
127.0.0.1and port numbers with your actual server's IP and port as needed.
All files are downloaded to/shared from the pi-sharing directory.
This directory is automatically created if it doesn't exist.
- Manan - Handled the redirection on the client side when the server responded with a new server.
- Aryan - Implemented redirection of clients to other servers during GET and files from the client during PUT.
- Jack - Implemented ADD_SERVER on both client and server side.
This code was extended from the 341 networking MP.