What is the timeout for a socket connection created using a connector constructor?
In Java SE 6, the following constructors for Socket will immediately connect the socket instead of calling it after the build:
Socket(InetAddress address, int port)Socket(InetAddress host, int port, boolean stream)Socket(InetAddress address, int port, InetAddress localAddr, int localPort)Socket(String host, int port)Socket(String host, int port, boolean stream)Socket(String host, int port, InetAddress localAddr, int localPort)
Although itβs nice and convenient, all that Java SE developers have created 500 ways to build a socket so that you can just look at a list of 500 to find the one that does what you want (instead of calling new Socket() on Socket#connect() ), none of the documents of these designers say what the connection timeout is or what they call connect(SocketAddress endpoint, int timeout) .
Perhaps the material in the docs constructor talking about createSocketImpl implies something about a timeout, or do some documents elsewhere say?
Does anyone know what the actual connection timeout is for any of these constructors?
Background: Well, assuming the spec is really ambiguous (did I think Java is portable?), I'm trying to understand why the client code freezes at seemingly random times. I have code that calls some open source library that calls one of these constructors. I want to know if a call to one of these constructors could make the timeout endless or very long. I donβt know which version of the JDK the client is using, so it would be nice if the spec talked about a timeout somewhere. I think I can probably get the JDK version from my client, but it will probably be a private JDK. In this case, could I deploy the code in my version of the SE library to find out? It's complicated? Will I go to jail?
source share