public ServerSocket(int port,int backlog)
Creates a server socket, bound to the specified port. A port of 0 creates a socket on any free port.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. 看了JDK文档,还是不太懂,有谁能讲得明白点吗?
python也有这个属性,假设设backlog=5,而我用>5个client去连接,竟然不报错
Creates a server socket, bound to the specified port. A port of 0 creates a socket on any free port.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. 看了JDK文档,还是不太懂,有谁能讲得明白点吗?
python也有这个属性,假设设backlog=5,而我用>5个client去连接,竟然不报错
If a connection indication arrives when the queue is full, the connection is refused.
程序是不会报错,只是ServerSocket拒绝该连接。
backlog并不是该服务器能同时支持的连接数。
所以只有你不accept去测试才能看到连接被拒绝。
参见
http://expert.51cto.com/art/200702/40196.htm