Sha256: d700b5059f55b454c0ce6514ed59e82a8231c0bfbc4ef52d8c861b381ef414dc

Contents?: true

Size: 374 Bytes

Versions: 1

Compression:

Stored size: 374 Bytes

Contents

require 'socket'
require 'timeout'


module IsPortOpen
  def port_open?(ip, port = 22)
    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

    false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rodeo_clown-0.1.0 lib/rodeo_clown/is_port_open.rb