# File lib/net/ping/tcp.rb, line 37 def ping(host=@host) super(host) bool = false tcp = nil start_time = Time.now begin Timeout.timeout(@timeout){ begin tcp = TCPSocket.new(host, @port) rescue Errno::ECONNREFUSED => err if @@service_check bool = true else @exception = err end rescue Exception => err @exception = err else bool = true end } rescue Timeout::Error => err @exception = err ensure tcp.close if tcp end # There is no duration if the ping failed @duration = Time.now - start_time if bool bool end