Skip to content

vidhhya1/Peer2Peer-ChatApplication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CryptoKnights

Assignment : Peer-to-Peer Chat Application

Team Name - "CryptoKnights"

Team Members :

Janapareddy Vidya Varshini - mc230041013
Korubilli Vaishnavi - mc230041016
Mullapudi Namaswi - mc230041023

✦ Note : Our code handles the Bonus question also.

✦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.

✦🚀 Features:

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.

📌 How It Works

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.

✦ Concepts Involved:

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

✦ How to run the code :

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

🌐 How to Connect & Communicate

✦Connecting to Static Peers

When a peer starts, it automatically attempts to connect to the following static peers:
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.

✦Menu Options

Option 1 : Send Message

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.

Option 2 : Query Active Peers

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.

Option 3 : Connect to Active Peers

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.

Option 4 : Quit

Exits the chat application and goes to offline.
Automatically disconnects from peers before shutting down.

Option 5 :Exit

If we message **exit** to a particular peer then this sender(peer) gets removed from active peer of that particular receiver peer

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages