You want to use asynchronous I / O with an I / O completion port (IOCP).
This is too much to explain briefly, but any Windows application that must support a large number of parallel sockets must use IOCP.
IOCP is essentially a work queue that provides threading to Windows. You put the termination package in IOCP, and then another thread deletes it and works with it.
You can also associate many types of descriptors that support overlapping operations, such as sockets, in IOCP. When you associate a descriptor with IOCP, overlapping operations such as WSARecvautomatically send a completion packet to the corresponding IOCP.
, , , 1000 . , IOCP. WSARecv 1000 , . , IOCP. , , .