def connect_nonblock( addr, timeout )
      sockaddr = ::Socket.pack_sockaddr_in(addr[1], addr[3])
      sock     = blank_socket()
      sock.connect_nonblock( sockaddr )
      return sock
    rescue Errno::EINPROGRESS
      if !wait_writable(timeout, sock)
        raise Timeout, "Could not connect to #{host}:#{port} within #{timeout} seconds"
      end
      return connect_nonblock_finalize( sock, sockaddr )
    rescue => ex
      raise Error, "Could not connect to #{host}:#{port}: #{ex.class}: #{ex.message}", ex.backtrace
    end
def connect_nonblock( addr, timeout )
      sockaddr = ::Socket.pack_sockaddr_in(addr[1], addr[3])
      sock     = blank_socket()
      sock.connect_nonblock( sockaddr )
      return sock
    rescue Errno::EINPROGRESS
      if !wait_writable(timeout, sock)
        raise Timeout, "Could not connect to #{host}:#{port} within #{timeout} seconds"
      end
      return connect_nonblock_finalize( sock, sockaddr )
    rescue => ex
      raise Error, "Could not connect to #{host}:#{port}: #{ex.class}: #{ex.message}", ex.backtrace
    end
Internal: Connect to the give address within the timeout.

 Make an attempt to connect to a single address within the given timeout.

 Return the ::Socket when it is connected, or raise an Error if no
 connection was possible.