I’ve just been playing around with a few things and stumbled accross a really neat ruby lib called ‘timeout’. I used it to make a quick check for network connectivity like so:



require 'timeout'
require 'socket'

begin
  timeout(10) do
    TCPSocket.new("www.rubyforge.org", 80)
  end
    puts true
rescue
  puts false
end

For so few lines thats a really neat; I thought so at least! :-)

Sorry, comments are closed for this article.