module VCR::Ping

@private

Public Class Methods

pingecho(host, timeout=5, service="echo") click to toggle source
# File lib/vcr/util/internet_connection.rb, line 14
def pingecho(host, timeout=5, service="echo")
  begin
    timeout(timeout) do
      s = TCPSocket.new(host, service)
      s.close
    end
  rescue Errno::ECONNREFUSED
    return true
  rescue Timeout::Error, StandardError
    return false
  end
  return true
end

Private Instance Methods

pingecho(host, timeout=5, service="echo") click to toggle source
# File lib/vcr/util/internet_connection.rb, line 14
def pingecho(host, timeout=5, service="echo")
  begin
    timeout(timeout) do
      s = TCPSocket.new(host, service)
      s.close
    end
  rescue Errno::ECONNREFUSED
    return true
  rescue Timeout::Error, StandardError
    return false
  end
  return true
end