Fork-N-Forge / Python-Sala

Python-Sala is the Hub of standard python projects.
4 stars 51 forks source link

Added a Chat Application Using Python #39

Closed mrsamirr closed 8 months ago

mrsamirr commented 8 months ago

7 Issue Solved

To run This Python Program :

Execute chat_server.py on one terminal Execute chat_client.py on multiple terminals to start chat clients Type messages on each client terminal to broadcast to other clients

Implementation : The server uses Python's socket module to create a TCP socket. The socket listens for connections from clients and spawns a new thread whenever a client connects.

The thread handles all communication for that particular client only. It receives messages from the client and broadcasts the message to all other clients by looping through the list of connected sockets.

The client simply connects to the server socket, takes user input to send messages, and prints any messages received from the server.