On 8/30/06, Matt Todd <chiology / gmail.com> wrote: > OK, so, I quickly googled and was not able to find anything specific, but > what I'm trying to do is find an elegant way to check for a network/internet > connection. (I specifically need the internet, but a network connection > needs to be preset as well for that... except for dial up? Gah.) > > So, from your collection experiences, what do you think is the best, most > elegant way to check for a network connection or an internet connection? > Should I just ping an address? > > And, sorry if I missed something obvious. > > M.T. > > This isn't easy to do, in the general case. I assume you're just trying to find out if you have a live connection to the WWW (including firewall openings and DNS availability), so you could try this: TCPSocket.new( "www.rubyforge.org", 80) If it doesn't throw anything, you're golden. Make sure to add a timeout loop (I usually wait no more than 4 seconds) because depending on what is wrong, this call may hang for a long time. Don't use ping- many firewalls block it.