Module: VCR::Ping

Defined in:
lib/vcr/util/internet_connection.rb

Class Method Summary collapse

Class Method Details

.pingecho(host, timeout = 5, service = "echo") ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vcr/util/internet_connection.rb', line 9

def pingecho(host, timeout=5, service="echo")
  begin
    Timeout.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