Module: SocketHelper
- Defined in:
- lib/joe_utils/helpers/socket_helper.rb
Instance Method Summary collapse
Instance Method Details
#is_port_open?(ip, port) ⇒ Boolean
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/joe_utils/helpers/socket_helper.rb', line 5 def is_port_open?(ip, port) begin Timeout::timeout(1) do s = TCPSocket.new(ip, port) s.close return true end rescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH # don't do anything end false end |