Checking for active Internet connection - Delphi.

Sabbz

Well-Known Member
Joined
Jan 31, 2008
Messages
261
Reaction score
0
Location
Johannesburg
Hey guys/girls,

I've been searching the net for a few hours now, but can't seem the find what I'm looking for: So I'll ask it here in the hopes that someone knows the answer.

I'm looking for a way to check if I am connected to the internet. Unfortunately, I have only found two ways of doing this, neither of which work since I am connected to the internet via LAN (I disconnected from the LAN and it continued to tell me that I was connected).

function InetIsOffline(Flag: Integer): Boolean; stdcall; external 'URL.DLL'; doesn't work.

and neither does the one on
http://delphi.about.com/b/2005/04/22/how-to-check-for-internet-connection-using-delphi-code.htm

Anyone ever used written an application that needs to check for an internet connection via LAN?

Any help is greatly appreciated, thanks in advance :)

Regards
 
Nope. Not possible. And, not advisable.

The only thing you can do is check to see if the computer can access the internet resource that you're trying to access.

People used to write software that checked for dial-up connections running, but because of the amazing variety of way of connecting to the internet, there is no real way to check anymore.

I simply do a simple socket connection to the server that I want to connect to, and if it's not there, I assume that I am not connected, though this could just mean that my destination server is off, but then again .. I usually have at least 2 servers to connect to on the internet (redundancy) so then I try to connect to the other one, and if they're both unavailable .. well .. then ...

Also ... when the computer attempting to connect responds with a "connect failed" in less than 1ms, then you can be pretty sure that that computer is not connected to anything even resembling the net.
 
And OP why don't you want use the standard collection and try to modulate situation arround that, not vice versa.
 
Top
Sign up to the MyBroadband newsletter
X