tags:

views:

60

answers:

1

Can we get the state (free space) of a java ServerSocket queue ??

The goal is to throw an exception when it's full ...


Some details about the ServerSocket queue :

Class ServerSocket

...

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.

...

ServerSocket(int port, int backlog)

...

The maximum queue length for incoming connection indications (a request to connect) is set to the backlog parameter. If a connection indication arrives when the queue is full, the connection is refused.

+1  A: 

No, the queue is managed by the OS, out of the SDK's purview.

Jonathan Feinberg
but the javadoc says that you can specify the length of the queue : "The maximum queue length ... is set to the backlog parameter." it means that the SDK has an access to it ? no ?
wj
You can see the source code for yourself, but yes, the SDK passes along the requested queue size to the OS, which establishes the server socket and its queue.
Jonathan Feinberg
THX for the details !!
wj