gpt4 book ai didi

c# - 如何确定 Socket.Listen() 的 MaxConnections?

转载 作者:太空狗 更新时间:2023-10-29 21:54:06 26 4
gpt4 key购买 nike

System.Net.Sockets.Socket.Listen() 函数需要一个 backlog 参数,它是 Listen()< 的最大连接数 可以排队。

From the MSDN documentation:

To determine the maximum number of connections you can specify, retrieve the MaxConnections value.

So I click on MaxConnections and the link takes me to the page for SocketOptionName Enumeration, which says:

MaxConnections: Not supported; will throw a SocketException if used.

所以这个 MaxConnections 枚举的文档说不要使用它,但没有给出替代方案。如何确定最大连接数,以便将值传递给 Socket.Listen() 函数?

最佳答案

当您尝试设置套接字选项 并使用MaxConnections 作为选项 名称时,将抛出异常,例如

listenSocket.SetSocketOption(..., SocketOptionName.MaxConnections, ...);

相比之下,作为 backlog 参数,它应该被使用。

关于c# - 如何确定 Socket.Listen() 的 MaxConnections?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23431947/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com