Sha256: f3a0c8286b55cc41f17164f95e5a34ac6946a19661a3a7eef4c59ca78a9b4f20
Contents?: true
Size: 743 Bytes
Versions: 22
Compression:
Stored size: 743 Bytes
Contents
module RSence module ArgvUtil # Tests, if the port on addr responds or refuses the connection. # Automatically replaces '0.0.0.0' with '127.0.0.1' def test_port( port, addr='127.0.0.1' ) require 'socket' begin addr = '127.0.0.1' if addr == '0.0.0.0' if RUBY_VERSION.to_f >= 1.9 sock = TCPSocket.open( addr, port ) else begin sock = TCPsocket.open( addr, port ) rescue NameError => e warn "TCPsocket not available, trying TCPSocket.." sock = TCPSocket.open( addr, port ) end end sock.close return true rescue Errno::ECONNREFUSED return false rescue => e warn e.inspect return false end end end end
Version data entries
22 entries across 22 versions & 2 rubygems