Skip to content
This repository

Description

The net-ping library provides an interface for pinging things in a variety of different ways.

Synopsis

Below is a bit of sample code that demonstrates some of the available Ping classes.

require 'net/ping'
include Net

Ping::TCP.service_check = true

pt = Net::Ping::TCP.new(host)
pu = Net::Ping::UDP.new(host)
pe = Net::Ping::External.new(host)
ph = Net::Ping::HTTP.new(uri)

if pt.ping?
  puts "TCP ping successful"
else
  puts "TCP ping unsuccessful: " +  pt.exception
end

if pu.ping?
  puts "UDP ping successful"
else
  puts "UDP ping unsuccessful: " +  pu.exception
end

if pe.ping?
  puts "External ping successful"
else
  puts "External ping unsuccessful: " +  pe.exception
end

if ph.ping?
  puts "HTTP ping successful"
else
  puts "HTTP ping unsuccessful: " + ph.exception
end

More Documentation

Ping Classes

Something went wrong with that request. Please try again.