What does the "backlog" argument in the ServerSocket constructor mean?
Created May 4, 2012
Tim Rohaly
A server must:
- Invoke the accept() method of ServerSocket to listen for a socket connection request
- Process the client request or hand off that request to a child process
- Repeat
ServerSocket tries to set the backlog to be 50 by default, although some OSes don't support a queue that large or don't allow the queue length to be modified.
When a client requests a connection and the queue is full, the request will fail with a ConnectionException. Increasing this backlog value may prevent some refused connections, but won't help to process these connections any faster and doesn't affect the maximum number of simultaneous connections allowed.