Regardless of the programming language you use, offering only asynchronous sockets is bad advice. It is true that all problems can be solved using asynchronous, but not all (for example, 100,000 connections) can be solved using synchronous. But in most cases, the problems are usually simpler (& lt; 100 connections).
In my experience, (mediocre) programmers tend to get lost in the mess they create using asynchronous sockets, while processing a synchronizing socket in a separate thread is simple, straightforward, and more convenient to maintain. Creating a thread under Windows is expensive, provided the operating system is correct, it is much less overhead (5 on x86 / Linux). In addition, it does not require 1 MB of RAM for the stream (at least not with the native program), but several kilobytes for the stack and state (registers).
In addition, many argue that synchronous socket programming is slower, but this is not always the case. Context switches (for other threads) come at a cost, but asynchronous socket interfaces are also expensive for the operating system kernel.
As always: I chose the solution that best suits the situation.
source share