A real-time terminal-based chat application built using C++ and Socket Programming for both Linux-based server and client communication.
- Multi-client support with concurrent communication via multi-threading
- Real-time chat system with colored terminal output for different users
- Graceful exit using signal handling (
Ctrl + C
) - Optimized for low-latency, responsive communication
- Lightweight and runs entirely in terminal (no GUI dependencies)
- C++
- POSIX Sockets
- Multithreading (
<thread>
,<mutex>
) - Linux system calls:
socket()
,bind()
,listen()
,accept()
,connect()
,send()
,recv()
- ANSI escape sequences for terminal coloring
g++ server.cpp -o server -pthread
g++ client.cpp -o client -pthread
./server
./client
π Note: Both server and client must run on the same machine or within the same network. You can also replace
INADDR_ANY
with a specific IP if required.
server.cpp
- Handles multiple clients, message broadcasting, and client managementclient.cpp
- Connects to server, sends/receives messages with UI feedback
- Concurrent programming with thread safety
- Terminal manipulation and formatting
- Custom protocol for broadcasting messages
- Use of
mutex
andsignal
for safe thread and process control
This project is for educational purposes only. Contributions and forks are welcome!