A lightweight multi-client chat server implemented in C++ using the POSIX select() and POLL() API. The server handles multiple client connections concurrently and supports real-time message broadcasting from the server console.
- โ
Supports multiple clients using a single-threaded
select()andPOLL()API. - โ
Server can send messages to all connected clients via
stdin - โ
Thread-safe message queue using
std::queue+std::mutex - โ Gracefully handles client disconnections
- โ
Uses low-level system calls:
socket,bind,listen,accept,read,send,select
Make sure you're compiling on a Unix-like system (Linux/macOS or WSL on Windows).
g++ -std=c++17 -pthread server.cpp -o chat_server