Having issue with testing “backlog” as per ServerSocket(int port, int backlog)

眉间皱痕 提交于 2019-12-25 07:36:06

问题


As per ServerSocket(int port, int backlog), backlog indicates maximum length of the queue.

I created a simple server socket, with backlog as 1 using following code ServerSocket serverSocket = new ServerSocket(8001, 1); and my expectation was that when I will try to connect to this server with more than 1 client then I will get connection refused exception.

But when I tried to connect with this server from more than 1 client then I was able to connect even with 3 client in parallel and all were able to communicate with the server.

Am I missing something?


回答1:


The backlog parameter can be adjusted up or down by the platform. The actual minimum backlog was initially 5 in BSD 4.3 and it is now more like 50 or even 500 on some platforms. There is no API to determine the actual value used.



来源:https://stackoverflow.com/questions/41309474/having-issue-with-testing-backlog-as-per-serversocketint-port-int-backlog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!