Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: How can I watch for an active internet connection

by elwarren (Priest)
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
Domain Nodelet?
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 musing on the Monastery: (1)
As of 2023-03-31 02:26 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (74 votes). Check out past polls.