From: Yohanes Santoso Date: 2002-06-17T22:31:48+09:00 Subject: Re: network connection test Pierre Brengard writes: > Hello, > > Has someone any clue to write a test to see if the network is > accessible rather than this ugly method ? : > > > require 'socket' > def test_network_connection > begin > addr = IPSocket.getaddress > TCPSocket.gethostbyname('localhost')[0] Um... localhost (127.0.0.1) is always accessible in UNIX. I believe the same holds for Windows too. Also, 127.0.0.0/255 is always accessible too. It is a predefined connection in any TCP stack I've encountered (VMS, UNIX, Windows). No packet is ever sent on the wire when connecting to 127.0.0.1. I believe that testing connection to your gateway produce at least a good method to ensure that at least connection to your gateway is still functioning. Unfortunately, the method of getting the gateway of a particular machine is platform dependent. YS.