Advanced · Module 8 · Lesson 3 of 11
Synchronous Multiplexing: Non-Blocking Descriptors, select, and poll
Manage thousands of concurrent socket connections on a single thread using O_NONBLOCK, inspect readiness states with select and poll, and overcome FD_SETSIZE limits.
By the end you can
- Configure file descriptors for non-blocking I/O using fcntl and handle EAGAIN/EWOULDBLOCK
- Monitor multiple socket descriptors simultaneously using select and fd_set bitmasks
- Eliminate FD_SETSIZE limitations and destructive bitmask overhead using poll and struct pollfd
- Trace linear kernel polling scans and quantify the O(N) scalability bottleneck
Builds on Protocol-Independent Networking: getaddrinfo and Dual-Stack IPv4/IPv6.
01 · A question first
Why does a single slow client that pauses midway through sending an HTTP request freeze an entire single-threaded server for all other users, and how can one thread monitor hundreds of sockets simultaneously without spawning a single thread?
Make a guess before you read on.
02 · The idea
Members only
Unlock the full lesson
This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.
What's inside
- Start with the problem
- How the idea works
- Production Implementation: Single-Threaded Echo Server Using poll()
- Why it is correct
- What it costs: The O(N) Scalability Wall
- Pitfalls and variations
- Where it is used
03 · Practice
Asked in interviews
Something wrong with this lesson? Report a problem