Korubilli Vaishnavi - mc230041016
Mullapudi Namaswi - mc230041023
✦Through this code we implemented a peer-to-peer chat program in Python using sockets and threading that enables simultaneous sending and receiving messages, supports multiple peers, and allows users to query and retrieve the list of peers from which it had received messages. It also maintains a list of active peers and ensures connectivity with predefined static peers. Multiple instances of the code can be run in seperate terminal environments to form a peer to peer chat network.
1.Establish a server that listens for incoming connections from peers.2.Send and receive messages between peers.
3.Automatically connect to a list of static peers upon startup.
4.Maintain a list of active peers and remove inactive ones.
5.User-friendly menu for managing connections and messaging.
6.Supports peer disconnection handling.
Each peer runs a *TCP server* on a specified port to listen for incoming connections. When a new peer starts, it attempts to connect to **static peers** and maintains an updated list of active peers. 1. Peer-to-Peer Networking
2. Socket Programming
3. Multithreading
4. Message Formatting and Serialization
5. Peer Discovery
6. Static Peers
7. Connection Management
8. User Interface
1. Run the python file in the command prompt or in terminal.
2. Enter your name.(Ex:Peer1)
3. Enter your port number.
4. Once a peer is running, the following options are available:
| Option Description |
|---|
| 1. Send a message to a specific peer |
| 2. Display the list of active peers |
| 3. Connect to all active peers |
| 0. Exit the application |
1.10.206.4.122:1255
2.10.206.5.228:6555
If a static peer is online, a successful connection is established and message is shown.
Manually send a message to a known peer.
The user must enter:
1.The recipient's IP address.
2.The recipient's port number.
3.Then enter your message
The system then: Establishes a connection to the target peer.
And the message gets displayed to that peer
If the connection fails, an error message is displayed.
Displays a list of all active peers and their connection status.
The system:
1.Checks if previously stored peers are still online.
2.Removes inactive peers from the list.
3.Displays active peers along with their IP, port, and name.
Sends a "connect" message to all previously discovered active peers.
If a peer responds with "connect_ack", their name is updated in the list.
Useful if you manually added new peers but haven't communicated yet.
Exits the chat application and goes to offline.
Automatically disconnects from peers before shutting down.
If we message **exit** to a particular peer then this sender(peer) gets removed from active peer of that particular receiver peer