title: What's the connection timeout of a socket created with a connecting constructor?
body: <p>What's the connection timeout of a socket created with a connecting constructor?</p>
  
  <p>In Java SE 6, the following constructors for Socket will connect the socket right away instead of you having to call connect on it after construction:</p>
  
  <ul>
  <li><code>Socket(InetAddress address, int port)</code></li>
  <li><code>Socket(InetAddress host, int port, boolean stream)</code></li>
  <li><code>Socket(InetAddress address, int port, InetAddress localAddr, int localPort)</code></li>
  <li><code>Socket(String host, int port)</code></li>
  <li><code>Socket(String host, int port, boolean stream)</code></li>
  <li><code>Socket(String host, int port, InetAddress localAddr, int localPort)</code></li>
  </ul>
  
  <p>While it's nice and convenient and all that the Java SE folks created 500 ways of constructing a socket so you can just browse the list of 500 to find the one that sort of does what you want (instead of calling <code>new Socket()</code> followed by <code>Socket#connect()</code>), none of the docs of these constructors says what the connection timeout is or whether/how they call <code>connect(SocketAddress endpoint, int timeout)</code>.</p>
  
  <p>Perhaps the stuff in the constructor docs talking about <code>createSocketImpl</code> imply something about the timeout, or some docs somewhere else say it?</p>
  
  <p>Anyone know what the actual connection timeout for any of these constructors is?</p>
  
  <hr>
  
  <p>Background: Okay, assuming the spec is really ambiguous (I thought Java is portable?), I'm trying to figure out why a customer's code freezes at seemingly random times. I have some code that calls some open source library which calls one of these constructors. I want to know whether calling one of these constructors would have made the timeout infinite or very long. I don't know what version of the JDK the customer is using so it would be nice if the spec says the timeout somewhere. I guess I can probably get the JDK version from my customer, but it will probably be the closed source JDK. In that case, could I reverse-engineer the code in their version of the SE library to find out? Is it hard? Will I go to jail?</p>