Socket Connection Timeout issue

Can anyone explain how I can get a ConnectionException that states as the reason "conntection timed out" when I try to connect a socket without setting the timeout parameter?

socket = new Socket();

SocketAddress sAddr = new InetSocketAddress(host, port);

socket.connect( sAddr );

gives me:

java.net.ConnectException: Connection timed out

[377 byte] By [AlanGreenberga] at [2007-11-26 13:42:33]
# 1

That can happen if there is no response whatsoever from the target system. The client will send a TCP SYN segment and expect a TCP SYN-ACK segment in reply, or in the case of error an ICMP error packet (e.g. 'connection refused'). If it doesn't get either of these within its timeout it retries with double the timeout. It does this so many times, totalling a timeout of around 75 seconds, then you get your timeout message.

ejpa at 2007-7-8 0:00:29 > top of Java-index,Core,Core APIs...
# 2

> If it doesn't get either

> of these within its timeout it retries with double

> the timeout. It does this so many times, totalling a

> timeout of around 75 seconds, then you get your

> timeout message.

I thought normal connection timeouts were between 2 minutes and 5 minutes?

Or perhaps I am confusing that with the default send timeout?

jschella at 2007-7-8 0:00:29 > top of Java-index,Core,Core APIs...
# 3

Nope. As an example, on Windows there are three retries with an initial timeout of 6 seconds and exponential backoff on retry. So the total timeout is 6+12+24=42 seconds. The Unix/Linux algorithms are different, but they generally adds up to about 75 seconds. You don't need 5 minutes for acknowledging a SYN segment at the kernel level.

ejpa at 2007-7-8 0:00:29 > top of Java-index,Core,Core APIs...