synchronized void doConnect(InetAddress address,int port,int timeout) throws IOException {
synchronized (fdLock) {
    if (!closePending && (socket == null || !socket.isBound())) {
      NetHooks.beforeTcpConnect(fd,address,port);
    }
  }
  try {
    acquireFD();
    try {
      socketConnect(address,port,timeout);
synchronized (fdLock) {
        if (closePending) {
          throw new SocketException("Socket closed");
        }
      }
      if (socket != null) {
        socket.setBound();
        socket.setConnected();
      }
    }
  finally {
      releaseFD();
    }
  }
 catch (  IOException e) {
    close();
    throw e;
  }
}

synchronized void doConnect ( InetAddress address , int port , int timeout ) throws IOException { synchronized ( fdLock ) { if ( ! closePending && ( socket == null || ! socket . isBound ( ) ) ) { NetHooks . beforeTcpConnect ( fd , address , port ) ; } } try { acquireFD ( ) ; try { socketConnect ( address , port , timeout ) ; synchronized ( fdLock ) { if ( closePending ) { throw new SocketException ( "Socket closed" ) ; } } if ( socket != null ) { socket . setBound ( ) ; socket . setConnected ( ) ; } } finally { releaseFD ( ) ; } } catch ( IOException e ) { close ( ) ; throw e ; } }
the workhorse of the connection operation . tries several times to establish a connection to the given < host , port > . if unsuccessful , throws an ioexception indicating what went wrong .
