Search code examples
windowswinsock

listen() maximum queue size per Windows version


The Winsock function listen(socket, backlog) has a parameter to specify the size of the queue for pending connections. The program should pass SOMAXCONN to set the queue to its maximum size.

Question: What is the maximum queue size for each Windows version: 2000, XP, Vista, 7?

Thanks!

Reference: listen() on MSDN Library


Solution

  • What do you hope to achieve once you know the answer to this?

    There are many ways to improve the performance of connection acceptance, you should focus on that and not what the actual number of queued connections can be.

    The listen backlog should simply accommodate short term discrepancies between the rate at which the server software can accept new connections and the rate at which these new connections are arriving. You should strive to ensure that your server can accept new connections at a suitable rate, ideally by using AcceptEx() with IOCP for overlapped accept calls and posting a suitable number of overlapped accepts when your server starts and then topping these up as connections are established.

    I talk about this kind of thing on my blog, here and here.