class Seahorse::Client::H2::Connection

def connect(endpoint)

def connect(endpoint)
  @mutex.synchronize {
    if @status == :ready
      tcp, addr = _tcp_socket(endpoint)
      debug_output("opening connection to #{endpoint.host}:#{endpoint.port} ...")
      _nonblocking_connect(tcp, addr)
      debug_output('opened')
      if endpoint.scheme == 'https'
        @socket = OpenSSL::SSL::SSLSocket.new(tcp, _tls_context)
        @socket.sync_close = true
        @socket.hostname = endpoint.host
        debug_output("starting TLS for #{endpoint.host}:#{endpoint.port} ...")
        @socket.connect
        debug_output('TLS established')
      else
        @socket = tcp
      end
      _register_h2_callbacks
      @status = :active
    elsif @status == :closed
      msg = 'Async Client HTTP2 Connection is closed, you may'\
            ' use #new_connection to create a new HTTP2 Connection for this client'
      raise Http2ConnectionClosedError.new(msg)
    end
  }
end