Fundamentals 8 min read

Understanding Network I/O: Blocking, Non‑Blocking, Async & Multiplexing Explained

This article revisits fundamental network I/O concepts, clarifying the differences between blocking, non‑blocking, synchronous, asynchronous, and multiplexed models through clear explanations and illustrative diagrams, helping developers build a solid mental model of how data moves between processes and the kernel.

360 Zhihui Cloud Developer
360 Zhihui Cloud Developer
360 Zhihui Cloud Developer
Understanding Network I/O: Blocking, Non‑Blocking, Async & Multiplexing Explained

It is often said that reviewing the past helps us learn anew; in work we frequently hear colleagues say, “I know this, but I forgot the details, I need to Google it.” Knowledge should form a mental system rather than relying on constant searches. This article provides a concise summary of basic network I/O concepts—synchronous vs asynchronous and blocking vs non‑blocking—to refresh and deepen understanding.

Preface

In network programming, terms such as blocking, non‑blocking, synchronous, and asynchronous are frequently mentioned. What exactly are synchronous I/O, asynchronous I/O, blocking I/O, and non‑blocking I/O, and how do they differ?

Data Flow

For a network I/O operation (using read as an example), two system entities are involved: the process (or thread) that initiates the I/O and the kernel. When a read occurs, it goes through two stages:

Waiting for the data to be ready.

Copying the data from the kernel to the process.

Remembering these stages is important because the differences among I/O models appear in how they handle each stage.

Network I/O Model Detailed Analysis

Common I/O models include blocking, non‑blocking, I/O multiplexing, and asynchronous I/O.

1. Blocking

Imagine going out to eat on a busy weekend. After ordering, you must wait in the restaurant until the food is ready before you can continue. This waiting period represents blocking I/O.

2. Non‑Blocking

Instead of waiting, you repeatedly check with the server whether the food is ready, going back and forth many times. This polling behavior illustrates non‑blocking I/O, where the process must keep checking the I/O status.

3. Multiplexing

With an electronic display showing order status, you can glance at the screen instead of repeatedly asking the server. This is analogous to I/O multiplexing (e.g., select , poll , epoll ).

4. Asynchronous

You place a delivery order by phone and then relax at home. When the food arrives, you are notified without having to check. This exemplifies asynchronous I/O, where the kernel handles the operation and notifies the process upon completion. Linux provides AIO library functions for async I/O, though they are rarely used; popular async libraries include libevent, libev, and libuv.

Synchronous vs Asynchronous

Synchronous I/O means the process initiates the operation and then waits (or polls) until it completes. Asynchronous I/O means the process initiates the operation and immediately returns to do other work; the kernel completes the I/O and later notifies the process.

Blocking vs Non‑Blocking

Simply put, if an operation cannot return immediately and forces the process to wait, it is blocking; if the operation returns immediately and the process can continue, it is non‑blocking.

Summary

From the diagrams it is clear that non‑blocking I/O and asynchronous I/O differ significantly:

In non‑blocking I/O, the process rarely blocks but must actively check the I/O status and, once data is ready, must explicitly call recvfrom to copy the data to user memory. Asynchronous I/O, on the other hand, hands the entire operation to the kernel; the kernel completes it and notifies the process, eliminating the need for the process to poll or copy data manually.
asynchronousI/O multiplexingnetwork I/Onon-blockingSystems Programmingblocking
360 Zhihui Cloud Developer
Written by

360 Zhihui Cloud Developer

360 Zhihui Cloud is an enterprise open service platform that aims to "aggregate data value and empower an intelligent future," leveraging 360's extensive product and technology resources to deliver platform services to customers.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.