Module: PoolParty::Pinger::ClassMethods

Defined in:
lib/mixins/pinger.rb

Instance Method Summary collapse

Instance Method Details

#ping_port(host, port = 22, retry_times = 400) ⇒ Object

Test to see if the host has the available port open for response.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/mixins/pinger.rb', line 6

def ping_port(host, port=22, retry_times=400)
  connected = false
  retry_times.times do |i|
    begin
      break if connected = TCPSocket.new(host, port).is_a?(TCPSocket)
    rescue Exception => e
      sleep(2)
    end
  end
  connected
end