Top Level Namespace
Defined Under Namespace
Instance Method Summary collapse
Instance Method Details
#port_open?(ip, port, seconds = 1) ⇒ Boolean
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rspec/infrastructure/nagios_matchers.rb', line 42 def port_open?(ip, port, seconds=1) Timeout::timeout(seconds) do begin TCPSocket.new(ip, port).close true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH false end end rescue Timeout::Error false end |