Non-blocking Chat Server with epoll
A high-concurrency chat server using Linux epoll for non-blocking I/O multiplexing across thousands of client sockets in a single thread, broadcasting messages between connected clients. Learners practice epoll-based event loops, non-blocking socket programming, and efficient buffer management in C++.
- Estimate
- ~12.5h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
epoll · sys/socket.h
Project roadmap
- 01
Set up the non-blocking listening socket
~1.5hCreate a TCP socket set to non-blocking mode and register it with an epoll instance.
- 02
Implement the epoll event loop
~2.5hBuild the core loop calling epoll_wait and dispatching readable/writable events to handlers.
- 03
Handle partial reads/writes with per-client buffers
~3hMaintain per-connection read/write buffers to correctly handle partial TCP reads and writes without blocking.
- 04
Implement message broadcasting
~2hParse complete messages from client buffers and queue them for writing to all other connected clients.
- 05
Handle client disconnects and errors
~1.5hDetect EPOLLHUP/EPOLLERR and closed connections, cleaning up sockets and buffers safely.
- 06
Load-test with many concurrent connections
~2hWrite a test client script that opens many simultaneous connections to validate scalability.
Resources
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack