Blocking Mode
It is the default socket method and the most common method, that is, function blocking until the call is completed. See the previous example.
Possible blocking functions include connect (), accept (), read and write functions, select (), poll (), and gethostbyname.
Non-Blocking Mode
If a program calls a function that may cause blocking, the function returns-1 and sets errno to EAGAIN or EWOULDBLOCK. The program can continue to run down. If the task corresponding to a function that may be blocked is completed, 0 is returned when the function is called again, indicating that the operation has ended.
Non-blocking mode can avoid program deadlocks, but the program needs to constantly check the status of each function that may be blocked. When an application uses a non-blocking mode socket, it uses a loop to continuously test whether a file descriptor has data readable (called polling ). Applications constantly polling the kernel to check whether I/O operations are ready. This operation is a waste of CPU resources, so it cannot be applied in reality. Generally, the non-blocking mode is used together with the synchronous I/O mode.
For more information about how to enter the non-blocking mode, see function description.
I/O multiplexing (synchronous I/O mode)
Use functions such as select () and poll () to implement synchronous I/O operations on multiple sockets. It can wait for multiple socket descriptors at the same time, and any of these socket descriptors enters the read-ready/Write-ready/error state, the select () function can return. See function descriptions and programs
Signal-driven I/O
Asynchronous I/O
Address: http://www.aka.org.cn/Lectures/002/Lecture-2.1.8/Lecture-2.1.8/index.htm