我在应用程序中使用客户端-服务器机制来传输内部数据。 服务器部件之一应设计为一次服务一个请求,没有线程,没有积压。我发现奇怪的功能然后使用:
serverport = new ServerSocket(port, 1, InetAddress.getLoopbackAddress());
即使一个连接已积压,此连接仍会继续接收传入连接吗? 有什么建议吗?我该如何解决这个问题?
最佳答案
正如 Javadoc 中所述:
The
backlog
argument is the requested maximum number of pending connections on the socket. Its exact semantics are implementation specific. In particular, an implementation may impose a maximum length or may choose to ignore the parameter altogther. The value provided should be greater than 0. If it is less than or equal to 0, then an implementation specific default will be used.
关于Java SocketServer 不受积压值限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32885119/