This project implements a hybrid peer-to-peer (P2P) network system for distributed resource sharing. It combines centralized server coordination with direct client-to-client communication, facilitating resource announcements, queries, and file transfers. The system supports scalability, efficient resource sharing, and fault-tolerant communication.
- Building hybrid P2P networks with centralized and decentralized components.
- Implementing multithreading for handling concurrent client requests.
- Utilizing Berkeley sockets for TCP and UDP communication.
- Designing dynamic data structures for user and resource directories.
- Integrating client liveness checks and non-blocking file transfers.
- C Programming Language: For efficient low-level control of network operations.
- Berkeley Sockets: To implement TCP and UDP communication.
- POSIX Threads: For multithreading and synchronization.
- Makefile: For compiling and managing the project build process.
- make
- ./server
- ./client <server_ip> Follow the on-screen prompts to register with the server, announce resources, query resources/users, and download files.
This screenshot shows the server running and logs, resource announcements, and liveness checks.

Here, a client announces resources, and the server updates its directory accordingly.

This screenshot shows a client querying the server for available resources.

This console output captures a client downloading a file directly from another client via TCP. This program also takes into account that different clients may have a resource named the same, yet different files, so it allows the user to choose who to download from if thats the case.
--- MENU ---
1. Announce a resource
2. Query available resources
3. Query active users
4. Download a resource
5. Exit
Select an option: 4
Resources:
Capture.PNG (Owner: Bob, IP: 192.168.1.200, TCP Port: 55211)
MSP2PIN.pdf (Owner: Bob, IP: 192.168.1.200, TCP Port: 55211)
test.txt (Owner: Bob, IP: 192.168.1.200, TCP Port: 55211)
cool_stuff.txt (Owner: Sally, IP: 192.168.1.109, TCP Port: 62102)
deadlift.mp4 (Owner: Sally, IP: 192.168.1.109, TCP Port: 62102)
test.txt (Owner: Sally, IP: 192.168.1.109, TCP Port: 62102)
test.py (Owner: Charlie, IP: 192.168.1.200, TCP Port: 55215)
Enter the name of the resource to download: test.txt
Available owners for resource 'test.txt':
1. Bob 192.168.1.200 55211
2. Sally 192.168.1.109 62102
Select an owner (1-2): 2
Downloading resource 'test.txt' from Sally (192.168.1.109:62102)
Resource 'test.txt' downloaded and saved as 'downloaded_Sally_test.txt'