RFR: 7116990: (spec) Socket.connect(addr,timeout) not clear if IOException because of TCP timeout [v2]

Mark Sheppard msheppar at openjdk.org
Wed Jun 11 21:22:28 UTC 2025


On Wed, 11 Jun 2025 12:38:43 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> I think it is an unnecessary quantification, is somewhat inaccurate, and set an expectation of a developer that this is gospel or axiomatic. Indicating that  it is OS dependent should be sufficient.
>
>> Alan @AlanBateman, do you suggest we continue with this text or would any update be necessary?
> 
> I think it's helpful here to give some indication in this API note as what the timeout might be. It doesn't really matter if it says 60s or 75s, the point is that establishing a TCP connection is subject to a timeout imposed by the operating system. It helps for cases where someone calls connect with a timeout of say 300_000 (5 minutes) and is surprised to get ConnectException "Operation timed out" after a minute or so. This is exactly what prompted JDK-7116990, someone called connect with a timeout that is larger than the OS configured timeout.

Looking at this on the 3 main OS platforms (Windows, OL and macOS) and running a simple test to trigger a connect timeout then finding are

macOS the connect timeout is 75 seconds as this is derived from 4.3 BSD

If OL linux has a syn retries set to 6 and an RTO == 1 sec then it’s connect timeout is 130 seconds approx 
That’s initial syn timeout of 1 seconds and then 6 retries totalling 127 seconds

Windows by default connect is 21 seconds
RTT == 3 seconds and two connect retries
Initial syn timeout 3 seconds + 2 retries at 6 and 12 seconds == 21 seconds

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25690#discussion_r2141133716


More information about the net-dev mailing list