FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
XP Pro - Service Pack 2
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Calling the connect(SockAddress dest, int timeout) method of Socket does not timeout correctly on Windows in 1.5.0.
For instance, passing a timeout of 3 seconds to the connect call results in an actual timeout of over 10 seconds (times vary - usually around 16 seconds).
This behaved correctly under 1.4.x. Passing a 3 second timeout would return in 3 seconds.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile sample program.
2. Run, passing arguments for IP address and timeout to use in Socket.connect() call. To observe timeout misbehavior, pass an IP address on your local network for a machine that does not exist. First arg is IP address, second is timeout in milliseconds.
Example: java socktest 192.168.0.50 3000
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect output of:
connect timed out: 3000
(or just slightly over 3000)
Where 3000 is the timeout you pass in (3000 milliseconds in this case)
ACTUAL -
Output under 1.5 is a time much larger than the passed in time:
connect timed out: 16534
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.net.*;
public class socktest {
public static void main(String [] args) throws Exception {
Socket s = new Socket();
long begin = System.currentTimeMillis();
try {
s.connect(new InetSocketAddress(args[0], 80), Integer.parseInt(args[1]));
} catch (Exception e) {
System.out.println(e.getMessage()+
": "+
(System.currentTimeMillis()-begin));
}
}
}
---------- END SOURCE ----------
Release Regression From : 1.4.2
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
Release Regression From : 1.4.2
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
###@###.### 2005-2-03 00:03:24 GMT