[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] testing for net connectivity



I have used 'inet_aton()' for this purpose with some success. 
On-line, with a functioning connection to your dial-up ISP, it will 
return the four-character internet address for any valid host. 
Off-line it returns 'undef'. (I can't give a bankable assurance it is 
a wholly water-tight solution however.)

The following lines might do what you want:

use Socket;
$ia = inet_aton('some.known.address') or die "$! No connection\n";
print "$ia\n";  #just for testing

For the address I sometimes use my own, i.e. "afco.demon.co.uk" or my 
ISP's web site "www.demon.net" -- anything valid will do.

Alan Fry

>Date: Thu, 30 Nov 2000 21:27:04 -0500
>Subject: [MacPerl] testing for net connectivity
>From: "Scott R. Godin" <webmaster@webdragon.net>
>To: <macperl@macperl.org>
>Sender: owner-macperl@macperl.org
>
>
>How would I program MacPerl to test for whether or not I have a working
>internet connection before performing other tasks .. I'd like it to die more
>gracefully if possible :)
>
>being on a flaky dialup instead of the cool cable/dsl solutions, makes this
>a near necessity if I want to run timed regular scripts.

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org