Sha256: aa4fa7f51aeacc7becd3c585c79e5e8af0c912ffbc777badeaefb2e156f57dc7

Contents?: true

Size: 376 Bytes

Versions: 25

Compression:

Stored size: 376 Bytes

Contents

require 'socket'
require 'timeout'

class Pinger

  def is_port_open?(ip, port)
    begin
      Timeout::timeout(1) do
        begin
          s = TCPSocket.new(ip, port)
          s.close
          return true
        rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
          return false
        end
      end
    rescue Timeout::Error
    end

    return false
  end
  
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
karl-loris-0.0.10 lib/pinger.rb
karl-loris-0.0.11 lib/pinger.rb
loris-0.5.2 lib/pinger.rb
loris-0.5.1 lib/pinger.rb
loris-0.5.0 lib/pinger.rb
loris-0.4.1 lib/pinger.rb
loris-0.4.0 lib/pinger.rb
loris-0.3.2 lib/pinger.rb
loris-0.3.1 lib/pinger.rb
loris-0.3.0 lib/pinger.rb
loris-0.2.3 lib/pinger.rb
loris-0.2.2 lib/pinger.rb
loris-0.2.1 lib/pinger.rb
loris-0.2.0 lib/pinger.rb
loris-0.1.7 lib/pinger.rb
loris-0.1.5 lib/pinger.rb
loris-0.1.4 lib/pinger.rb
loris-0.1.3 lib/pinger.rb
loris-0.1.2 lib/pinger.rb
loris-0.1.1 lib/pinger.rb