[英]How to determine MaxConnections for Socket.Listen()?
The System.Net.Sockets.Socket.Listen()
function requires a backlog
argument, which is the max number of connections that Listen()
can queue up. System.Net.Sockets.Socket.Listen()
函数需要一个backlog
参数,这是Listen()
可以排队的最大连接数。
From the MSDN documentation: 从MSDN文档中:
To determine the maximum number of connections you can specify, retrieve the
MaxConnections
value.要确定您可以指定的最大连接数,请检索
MaxConnections
值。
So I click on MaxConnections
and the link takes me to the page for SocketOptionName Enumeration
, which says: 因此,我单击
MaxConnections
,该链接将我带到SocketOptionName Enumeration
的页面,该页面SocketOptionName Enumeration
:
MaxConnections: Not supported;
MaxConnections:不支持; will throw a SocketException if used.
如果使用,将抛出SocketException。
So the documentation for this MaxConnections
enumeration says not to use it, but doesn't give an alternative. 因此,此
MaxConnections
枚举的文档说不要使用它,但没有其他选择。 How do I determine the max connections, so that I have a value to pass into the Socket.Listen()
function? 如何确定最大连接数,以便有一个值传递给
Socket.Listen()
函数?
Exception will be thrown when you will try to set socket option and use MaxConnections
as an option name, eg 当您尝试设置套接字选项并使用
MaxConnections
作为选项名称时,将引发异常。
listenSocket.SetSocketOption(..., SocketOptionName.MaxConnections, ...);
In contrast, as a backlog
argument it is meant to be used. 相反,
backlog
其用作backlog
参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.