Java套接字接受队列长度

发布于 2024-08-20 03:13:33 字数 158 浏览 3 评论 0原文

根据Sun关于ServerSocket的文档:

传入连接指示(连接请求)的最大队列长度设置为 50。如果在队列已满时连接指示到达,则连接将被拒绝。

如何增加队列长度?这是我服务器的瓶颈。

谢谢。

According to the Sun's documentation on ServerSocket:

The maximum queue length for incoming connection indications (a request to connect) is set to 50. If a connection indication arrives when the queue is full, the connection is refused.

How can I increase the the queue length? It's my server's bottle-neck.

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

故事和酒 2024-08-27 03:13:33

使用 ServerSocket带有 backlog 参数的构造函数

您可能还想考虑使用线程池(或者实际上是 ExecutorService)来分派传入请求。根据您的架构方式,这通常会带来更好的吞吐量。

Use the ServerSocket constructor with the backlog parameter.

You may also want to consider using a Thread pool (or really an ExecutorService) to dispatch incoming requests. Depending on how you architect it, this will generally lead to better throughput.

牵你的手,一向走下去 2024-08-27 03:13:33

使用构造函数的 backlog 参数 (Javadoc)。但请记住,您将无法将队列增加到超过操作系统限制。这是为了防止 SYN 攻击 - 请参阅这篇文章了解更多信息。

Use the backlog parameter of the constructor (Javadoc). Keep in mind that you won't be able to increase the queue past the operating system limits, though. This is to prevent SYN attacks - see this article for more information.

没有你我更好 2024-08-27 03:13:33

ServerSocket 还有另一个构造函数。

public ServerSocket(int port, int backlog)

其中 backlog 是您想要的连接队列大小。最大 50 仅适用于采用 int port 的默认构造函数

There is another constructor for ServerSocket.

public ServerSocket(int port, int backlog)

where backlog is the connection queue size you want. The max 50 only applied to the default constructor that takes int port

九八野马 2024-08-27 03:13:33

要限制连接被拒绝,请确保在对该轮询进行任何发送/接收处理之前处理每个选择轮询的所有连接请求。

To limit the connection refused be sure you process all of the connect requests for each select poll before doing any of the send/receive processing for that poll.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文