listen() 每个 Windows 版本的最大队列大小 [英] listen() maximum queue size per Windows version

查看:23
本文介绍了listen() 每个 Windows 版本的最大队列大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Winsock 函数 listen(socket, backlog) 有一个参数来指定待处理连接的队列大小.程序应通过 SOMAXCONN 将队列设置为其最大大小.

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.

问题:每个 Windows 版本的最大队列大小是多少:2000、XP、Vista、7?

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

谢谢!

参考:listen() 在 MSDN图书馆

推荐答案

一旦你知道了这个问题的答案,你希望实现什么?

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.

listen backlog 应该简单地适应服务器软件可以接受新连接的速率和这些新连接到达的速率之间的短期差异.您应该努力确保您的服务器能够以合适的速率接受新连接,理想情况下,通过将 AcceptEx() 与 IOCP 一起用于重叠接受调用并在您的服务器启动时发布适当数量的重叠接受,然后在建立连接时补充这些.

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.

这篇关于listen() 每个 Windows 版本的最大队列大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆