Socket connect timeout is dependent on the OS.
It is configurable since jdk1.4 through code by creating an unbound socket and using connect(SocketAddress, timeout)
If one uses java.net.URLConnection there are also:
sun.net.client.defaultConnectTimeout (default: -1)
sun.net.client.defaultReadTimeout (default: -1)
See http://java.sun.com/j2se/1.4.1/docs/guide/net/properties.html

Quite so. I forgot this was added in 1.4. Adding support for native connect timeout in HttpClient will require an interface change I think, so it will have to wait until at least 2.1. As always other thoughts are welcome.


Has anyone actually tried to contact a server that is down and received a timeout?
In my experience, trying to interrupt a socket while it is trying to connect (as in the TimeoutController) does nothing until the actual OS timeout kicks in.

I have and it seems to work. After a little investigation I agree with you. It seems that interrupting a thread blocked in Socket() does nothing. In our case though this is not really a problem since the socket is opened from a new thread. Once the timeout occurs the original thread interrupts the connect thread (which appears to do nothing) and then throws an exception. The timeout still occurs though it doesn't keep the socket from being opened. The only problem here is the possibility of an orphaned thread blocked in Socket().


Mike


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to