Class: Cloudscopes::Network
- Inherits:
-
Object
- Object
- Cloudscopes::Network
- Defined in:
- lib/cloudscopes/network.rb
Instance Method Summary collapse
Instance Method Details
#local_ip ⇒ Object
8 9 10 |
# File 'lib/cloudscopes/network.rb', line 8 def local_ip Socket.ip_address_list.detect {|intf| intf.ipv4? and !intf.ipv4_loopback? and !intf.ipv4_multicast? }.ip_address end |
#port_open?(port) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cloudscopes/network.rb', line 12 def port_open?(port) begin Timeout::timeout(1) do begin TCPSocket.new(local_ip, port).close return true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH return false end end rescue Timeout::Error return false end end |