I’m playing with ServerSocket and I don’t see / find what the limit of the backlog is. The docs don’t say anything about this:
http://download.oracle.com/javase/6/docs/api/java/net/ServerSocket.html#ServerSocket(int, int)
My code is like this:
serverSocket = ServerSocketChannel.open();
serverSocket.socket().bind(null, 10000);
but I assume that 10000 might be too much if a system doesn’t have enough RAM. So is there a way to determine the maximum value for backlog that I can use?
It seems like in c++ you can use SOMAXCONN – does something similar exist for Java?
If there were, it would be system dependent: for Windows
Linux states it a little differently but you would need to go through the sysctl interface (or possibly /proc).
In any case, it would appear you would need to execute some system specific code.
I believe most implementations will just use their maximum value if the specified value is “too big” so this may not be a concern for your application?