FULL PRODUCT VERSION :
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux minkir-laptop 3.8.0-28-generic #41-Ubuntu SMP Fri Jul 26 16:26:01 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
As described in ServerSocket constructor:
http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket%28int,%20int%29
"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. "
Based on POSIX interpretation backlog is only for indication purposes and application (JVM) should implement queue limit:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html
"The backlog argument provides a hint to the implementation which the implementation shall use to limit the number of outstanding connections in the socket's listen queue."
Backlog doesn't seem to be working with simple ServerSocket implementation, number of connections are not limited as described in constructor specification
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Take client-server example sources from:
https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html
Minor modification to KKMultiServer.java to set backlog:
ServerSocket serverSocket = new ServerSocket(portNumber, 10)
Launch KKMultiServer and many KnockKnockClient's.
Result - backlog is not limiting client to server.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
As backlog queue limit is reached, server shouldn't accept new connections (reset or ignore).
ACTUAL -
Backlog is not effective, number of client->server sockets established is not limited.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html
Minor modification to introduce backlog:
try (ServerSocket serverSocket = new ServerSocket(portNumber, 10)) {
while (listening) {
new KKMultiServerThread(serverSocket.accept()).start();
}
} catch (IOException e) {
System.err.println("Could not listen on port " + portNumber);
System.exit(-1);
}
---------- END SOURCE ----------
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux minkir-laptop 3.8.0-28-generic #41-Ubuntu SMP Fri Jul 26 16:26:01 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
As described in ServerSocket constructor:
http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket%28int,%20int%29
"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. "
Based on POSIX interpretation backlog is only for indication purposes and application (JVM) should implement queue limit:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html
"The backlog argument provides a hint to the implementation which the implementation shall use to limit the number of outstanding connections in the socket's listen queue."
Backlog doesn't seem to be working with simple ServerSocket implementation, number of connections are not limited as described in constructor specification
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Take client-server example sources from:
https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html
Minor modification to KKMultiServer.java to set backlog:
ServerSocket serverSocket = new ServerSocket(portNumber, 10)
Launch KKMultiServer and many KnockKnockClient's.
Result - backlog is not limiting client to server.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
As backlog queue limit is reached, server shouldn't accept new connections (reset or ignore).
ACTUAL -
Backlog is not effective, number of client->server sockets established is not limited.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html
Minor modification to introduce backlog:
try (ServerSocket serverSocket = new ServerSocket(portNumber, 10)) {
while (listening) {
new KKMultiServerThread(serverSocket.accept()).start();
}
} catch (IOException e) {
System.err.println("Could not listen on port " + portNumber);
System.exit(-1);
}
---------- END SOURCE ----------
- duplicates
-
JDK-6258215 Num of backlog in ServerSocket(int, int) should be mentioned more explicitly in API document
-
- Closed
-