Dev.to
6/30/2026

From one blocking accept() to epoll: a C TCP server up the I/O ladder, measured
Short summary
A TCP echo server is rebuilt seven times, evolving from blocking I/O (which serializes clients, causing 1.51-second latency) through non-blocking loops (burning 98% CPU) to select, poll, and epoll. Each version is measured to show tradeoffs: blocking is idle-efficient but stalls; polling wastes CPU; multiplexing needs OS support. The progression illustrates the C10K problem—serving ten thousand concurrent connections efficiently.
- •Blocking I/O avoids CPU waste but stalls when one client idles—the second client waited 1.51 seconds
- •Non-blocking loops fix stalling by polling, but burn 98% CPU even with no clients
- •select/poll/epoll use kernel notifications instead of polling, balancing efficiency with responsiveness
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



