On the Internet to read a lot of answers, also did not find the appropriate, perhaps this article is not the appropriate answer:)
Synchronous and asynchronous are concerned with the message communication mechanism, while blocking non-blocking is concerned with the state of the program while waiting for the result (message, return value) of the call.
Synchronous/asynchronous is the way the API is notified by callers. Blocking/non-blocking is the way the API caller waits.
synchronous, asynchronous, and blocking, non-blocking are composite relationships.
So there are 4 ways:
Synchronous blocking
Synchronous non-blocking
Asynchronous blocking
Asynchronous non-blocking
------------------------------------------------------------------------
Recv and Recvfrom:
Recv only the function returns after receiving the message, this is blocking.
The Recvfrom returns immediately, which is non-blocking.
For recvfrom, how do I receive a message because the function returns immediately? There are 2 ways of doing this:
Open a thread, keep the Select, this is synchronous
With an asynchronous mechanism, a message is notified when the system receives a message, which is asynchronous .
It seems that the above description only three kinds, blocking, synchronous non-blocking, asynchronous non-blocking, why?
because generally, since the use of blocking, with synchronization is good, (generally) with async a bit redundant , because the caller knows already received, but also need system notification?
I think that's why it's easy to confuse these 2 sets of concepts (there are few asynchronous blocking patterns, and some scenarios may need to be used).
Socket synchronous/Asynchronous vs. blocking/non-blocking differences