A blocking server associates waiting with a thread. When a thread calls recv() and no data is available, the operating system puts that thread to sleep until the socket changes state.
Non-blocking I/O separates waiting from the socket operation itself. A non-blocking recv() returns immediately when no bytes are available. The application uses a readiness API such as select() to ask:
This changes the server architecture. Instead of one blocked worker per connection, one event-loop thread watches many sockets, performs only the operations that are ready, stores unfinished work in per-connection state, and returns to the readiness check.
This chapter builds single-threaded non-blocking TCP echo servers in Python and Java. Both servers:
The key idea is not that non-blocking calls are always faster. It is that a thread no longer has to remain blocked for every idle connection.