Method: #port_bound?
- Defined in:
- lib/vagrant-subutai/packer/subutai_net.rb
#port_bound?(host, port) ⇒ Boolean
Checks if a port is not available
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/vagrant-subutai/packer/subutai_net.rb', line 10 def port_bound?(host, port) Timeout.timeout(1) do s = TCPSocket.new(host, port) s.close rescue nil return true end rescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, \ Errno::ENETUNREACH, Errno::EACCES, Errno::ENOTCONN, \ Errno::EADDRNOTAVAIL return false end |