i develop an echo server wit开发者_如何学Pythonh WSAEventSelect. It only allow 64 connections. What should i do.
That sounds suspiciously like the MAXIMUM_WAIT_OBJECTS
limit, which is 64. The function WaitForMultipleObjectsEx is limited by that number. That link talks about solutions. If you are using WSAWaitForMultipleEvents, it might be this since the documentation says it calls WaitForForMultipleObjectsEx.
Use more threads. Each thread can then handle 64 connections. It's quite possible to create 10-100 threads, depending on your hardware.
There are 3 options:
- Use more threads with each the maximum # handles to wait for
- Use WSAAsyncSelect instead of WSAEventSelect and use Window messages instead
- Use overlapped IO (this is quite complex but scales best to large number of clients)
The limit is imposed by the Kernel that a thread can wait to a maximum of 64 kernel objects in one WaitFor function.
2.Use WSAAsyncSelect instead of WSAEventSelect and use Window messages instead
I would only go for WSAAsyncSelect in the client side for simple implementations, never for a server!!
精彩评论