Multiple Socket Client Connecting to Server

I am developing a simulator application where the application starts several socket connections (about 1000 connections) to the server. I do not want to start so many threads to process these connections, since the system cannot process so many clients. Using Select doesn't make sense, since I need to iterate over 1000 connections, which can be slow. Please suggest me how to handle this scenario.

0
source share
2 answers

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. , ​​ , .

+3

1000 - , 1000 , . select() - .

0

All Articles