Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: How can I watch for an active internet connection

by elwarren (Curate)
on Dec 31, 2004 at 00:15 UTC ( #418440=note: print w/replies, xml ) Need Help??

in reply to How can I watch for an active internet connection

ActiveState Perl has Win32-IPConfig and Win32-IPHelper available via PPM. They will be able to tell you if your interface is up, whether you have a DHCP lease, whether there is a gateway on that interface (so you can guess that that's your internet connection.)

You'll still need to verify that you can connect through the network connection you find, but this will be a good start. I would suggest either pinging your dns server or making an http header request to a web server that you think is reliable, or possibly the web server you want to work against.

I say ping your dns server, because if you can't resolve names to addresses, you might not get very far anyway. Unless you're running a caching nameserver locally on your network or in your router.

Many networks are blocking ICMP packets from ping these days, as well as traceroute packets, so that's why I suggest the http request. Do the net a favor and just do the HEAD request instead of grabbing the entire page.

This should be enough to get you started. Good luck.
  • Comment on Re: How can I watch for an active internet connection

Replies are listed 'Best First'.
Re^2: How can I watch for an active internet connection
by boat73 (Scribe) on Dec 31, 2004 at 15:27 UTC
    Thanks for pointing me in the right direction.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://418440]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2019-05-22 23:09 GMT
Find Nodes?
    Voting Booth?
    Do you enjoy 3D movies?

    Results (140 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!