This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.
--- www.oreilly.com ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max = 183.6/183.6/183.6 ms 10 8Pinging a Machine | ||
---|---|---|
Code | Expected | Actual |
require 'ping' Ping::pingecho('oreilly.com') |
true | true |
Ping::pingecho('localhost') |
true | true |
Ping::pingecho('127.0.0.1') |
true | true |
Ping::pingecho('no.such.domain') |
false | false |
Ping::pingecho('222.222.222.222') |
false | false |
system('ping -c1 www.oreilly.com') |
64 bytes from 208.201.239.36: icmp_seq=0 ttl=42 time=27.2 ms |
|
# |
--- www.oreilly.com ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max = 27.2/27.2/27.2 ms |
Error! (Exception?) Here's stdout: |
Ping::pingecho('microsoft.com') |
false | false |
require 'net/http' Net::HTTP.start('microsoft.com') { 'success!' } |
"success!" | "success!" |
Net::HTTP.start('no.such.domain') { "success!" } |
SocketError: getaddrinfo: Name or service not known ... |
SocketError: getaddrinfo: Name or service not known from /usr/lib/ruby/1.8/net/http.rb:562:in `initialize' from /usr/lib/ruby/1.8/net/http.rb:562:in `connect' from /usr/lib/ruby/1.8/timeout.rb:48:in `timeout' from /usr/lib/ruby/1.8/timeout.rb:76:in `timeout' from /usr/lib/ruby/1.8/net/http.rb:562:in `connect' from /usr/lib/ruby/1.8/net/http.rb:555:in `do_start' from /usr/lib/ruby/1.8/net/http.rb:544:in `start' from /usr/lib/ruby/1.8/net/http.rb:440:in `start' from (irb):12 |