A multi-user TCP chat server using Python sockets and threads.
Implements:
- LOGIN
- MSG
- WHO
- DM
- PING → PONG
- Idle timeout + disconnect notifications
- Install Python 3.8+
- Clone or copy this project:
git clone <your-repo> socket-chat
cd socket-chat- Run the server
python3 chat_server.py - Connect two or more clients using either of the two ways:
A. Netcat:
nc localhost 4000
LOGIN Alice
MSG Hello everyone! B. Python client:
python3 chat_client.py --host 127.0.0.1 --port 4000 Client 1:
LOGIN ashutosh
OK
MSG hello everyone...how are all of you? Client 2:
LOGIN shristi
OK
MSG hey ashutosh!| Command | Description |
|---|---|
WHO |
Lists active users |
DM <username> <text> |
Sends a private message to the specified user |
PING |
Replies with PONG |
ERR |
Returned on invalid input |
INFO <username> disconnected |
Shown when someone leaves the chat |
Watch the working demo here: Demo