A lightweight terminal-based chat application implemented in Python using TCP sockets. It consists of a server and client that allow multiple users to chat in real-time over the network.
- Multi-client support (up to 10 simultaneous clients)
- User-friendly terminal interface with colored output
- Change your username on the fly with
/namecommand - Graceful handling of Ctrl+C and connection loss
- Reverse DNS lookup of client IP addresses on the server
- Broadcasts messages to all connected clients
- Distinguishes your own messages from others in the client UI
- Python 3.7 or newer
- termcolor — for colored terminal output
- dnspython — for reverse DNS lookup on server
-
Clone this repository:
git clone https://github.com/ShigrafS/CallNet_mvp.git cd CallNet_mvp -
Install dependencies:
pip install termcolor dnspython
By default, the server listens on all interfaces (0.0.0.0) and port 8080.
python server.pyExample output:
Server listening on port 8080 (max 10 clients)...
Run the client with the server IP (or hostname) and port:
python client.py SERVER_IP 8080Example connecting to a server on the same machine:
python client.py 127.0.0.1 8080-
Enter your display name when prompted:
Please Enter Your Name: -
Start chatting by typing messages after the prompt:
You: -
Incoming messages from others show the sender's name in cyan bold text.
-
Your own messages are shown as
You:in green bold text.
| Command | Description | Example |
|---|---|---|
/name NEWNAME |
Change your display name | /name Alice |
/quit or /exit |
Exit the chat client gracefully | /quit |
- Attempts reverse DNS lookup on client IPs.
- Rejects new clients when max capacity (default 10) is reached.
- Broadcasts all client messages to every other client.
- Cleans up disconnected clients automatically.
- Stop the server with
Ctrl+C(SIGINT) to shut down gracefully.
- Make sure client and server ports match.
- Open firewall ports if connecting across networks.
- The client expects newline (
\n) delimited messages. - The server currently does not echo your own messages back; clients show your messages locally.
- Use terminals that support ANSI colors for the best experience.
| Issue | Possible Cause / Solution |
|---|---|
| Connection refused | Server not running or wrong IP/port |
| "Server full." message | Maximum clients reached; wait or increase MAX_CLIENTS in server.py |
| No messages appearing | Make sure you entered your name and typed messages correctly |
| Reverse DNS errors | Normal if client IP has no PTR record |
- Modify
MAX_CLIENTSinserver.pyto change max clients. - Change
server_addresstuple inserver.pyto use a different port or bind address. - Extend client or server for more commands or encryption.
This project is provided as-is for learning and demo purposes.
Feel free to contribute or open issues if you find bugs or want features!
Happy chatting! 🎉