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.
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.
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
要限制拒绝的连接,请确保在执行该轮询的任何发送/接收处理之前,为每个选择轮询处理所有的连接请求。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.