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
In the space of time between calls to accept(), incoming client connection requests are stored in a queue maintained by the operating system. Subsequent calls to accept() remove requests from this queue, or block if there are no waiting clients. The “backlog” argument controls the length of this queue.
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.