Sha256: e3df7f03ec8ac92cf673eee9cf2f478559f7db2dc289254fae06f3192f36f4fb
Contents?: true
Size: 332 Bytes
Versions: 6
Compression:
Stored size: 332 Bytes
Contents
require 'socket' require 'timeout' # see http://stackoverflow.com/questions/517219/ruby-see-if-a-port-is-open 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
Version data entries
6 entries across 6 versions & 1 rubygems