You *could* use ICMP (popularly known as "ping") and try to reach a host like google.com, which would be what I think it's the correct way. That of course means you're also verifying whether you have a DNS server available. I believe you'll anyway be relying on that for whatever your need is.
But as a quickie, this will do require 'socket' begin TCPSocket.new 'google.com', 80 rescue SocketError STDERR.puts "not connected sir" end Replace error handling with whatever you need. Ping in Ruby: http://raa.ruby-lang.org/project/net-ping/. On Fri, Nov 20, 2009 at 3:53 PM, Joshua Partogi <[email protected]> wrote: > Hi all, > > I'm wondering if anyone has ever been in this situation before. I want > to be able to load files dynamically from the internet, but I need to > check whether the customer has internet connection or not. Is this > doable with Ruby? Has anyone done this before? > > Many thanks for the insights. > > -- > Certified Scrum Master > http://blog.scrum8.com | http://jobs.scrum8.com | http://twitter.com/scrum8 > > -- > > You received this message because you are subscribed to the Google Groups > "Ruby or Rails Oceania" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rails-oceania?hl=. > > > -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=.
