def connect(host, port, remote_pubkey)
      socket = create_connection host, port, @connect_timeout
      logger.debug "connecting to", peer: socket.peeraddr

      start_peer socket, remote_pubkey
      true
    rescue Errno::ETIMEDOUT
      address = "#{host}:#{port}"
      logger.debug "connection timeout", address: address, timeout: @connect_timeout
      @errors.add address, 'connection timeout'
      false
    rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ECONNREFUSED
      address = "#{host}:#{port}"
      logger.debug "connection error #{$!}"
      @errors.add address, "connection error #{$!}"
      false
    rescue
      address = "#{host}:#{port}"
      logger.debug $!
      @errors.add address, "connection error #{$!}"
      false
    end
def connect(host, port, remote_pubkey)
      socket = create_connection host, port, @connect_timeout
      logger.debug "connecting to", peer: socket.peeraddr

      start_peer socket, remote_pubkey
      true
    rescue Errno::ETIMEDOUT
      address = "#{host}:#{port}"
      logger.debug "connection timeout", address: address, timeout: @connect_timeout
      @errors.add address, 'connection timeout'
      false
    rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ECONNREFUSED
      address = "#{host}:#{port}"
      logger.debug "connection error #{$!}"
      @errors.add address, "connection error #{$!}"
      false
    rescue
      address = "#{host}:#{port}"
      logger.debug $!
      @errors.add address, "connection error #{$!}"
      false
    end
Connect to address (a 2-tuple [host, port]) and return the socket object.

 Passing the optional timeout parameter will set the timeout.