开发者

how break the 64 limit when using WSAEventSelect

开发者 https://www.devze.com 2022-12-20 04:20 出处:网络
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 W

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:

  1. Use more threads with each the maximum # handles to wait for
  2. Use WSAAsyncSelect instead of WSAEventSelect and use Window messages instead
  3. 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!!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号