This is a peer-to-peer (P2P) chat application developed for CS216: Introduction to Blockchain. It enables simultaneous sending and receiving of messages, supports multiple peers, and allows users to query and retrieve active peers.
- Simultaneous Send & Receive: Uses multithreading to enable real-time communication.
- Persistent Peer Tracking: Maintains a list of peers based on messages received.
- Active Peer Querying: Users can check which peers are currently online.
- Ephemeral Port Handling: Ensures consistent peer identification despite changing ephemeral ports.
- Mandatory Connection: Messages are always sent to two predefined IP addresses.
- Implements BONUS TASK: Connect to active peers
Your client must mandatorily send messages to the following peers:
- IP: 10.206.4.122 PORT: 1255
- IP: 10.206.5.228 PORT: 6555
To ensure consistency, messages must follow this format:
<IP_ADDRESS:PORT> <team_name> <message>
Example:
10.206.4.201:8080 blockchain hello
- Clone the repository:
git clone https://github.com/singhyash05/p2p-chat-BlockForge
- Navigate to the project directory:
cd p2p-chat-BlockForge - Run the script:
python3 p2p_chat.py
- Enter your team name and port number when prompted.
- Start the chat application.
- Enter the recipient's IP and port to send messages.
- Query active peers using the menu.
- Optionally, connect to active peers.
1. Send message
2. Query active peers
3. Connect to active peers
0. Quit
- If a peer reconnects using an ephemeral port, it might be misidentified as a new peer.
- The listening port of a peer is stored separately to ensure correct reconnection.
- Team Name: BlockForge
- Member 1: Yash Singh - Roll Number 230051019
- Member 2: Shorya Kshettry - Roll Number 230003070
- Member 3: Hardik Bansal - Roll Number 230001031