Best way to check if there is internet?

Dennis Lee Bieber wlfraed at ix.netcom.com
Mon Feb 7 11:55:39 EST 2022


On Mon, 7 Feb 2022 13:33:54 +0400, Abdur-Rahmaan Janhangeer
<arj.python at gmail.com> declaimed the following:

>Popular browsers tell: No internet connection detected. A function that
>goes in the same sense. Unless they too are pinging Google.com to check ...
>

	Ah, but WHEN do those browsers report that? When attempting to connect
to whatever the default "home" page has been set to? (Mine is configured to
use https://www.google.com as the default page -- if my router is down,
obviously the browser will time-out waiting for a response from Google, and
report "no network").

	Pretty much any discovery of "no network" occurs when the application
attempts to make a normal connection to some target -- using whatever
protocol is normal for that application -- and fails to get a response.
ping is not a solution -- it is possible for firewalls to be configured to
drop with no response specific packets. A firewall configured to DROP
rather than REJECT results in a machine that just "isn't there" to outside
poking. That doesn't mean that the network is down -- only that the machine
you tried to poke is ignoring you.

	Also, for a machine freshly booted, with no cache, even pinging Google
first requires making contact with a DNS server to ask for Google's IP
address. With no network, the DNS look-up will fail before ping even tries
to hit Google.

	Consider that UDP is often used in a "fire and forget" mode -- packets
get sent to the network interface for forwarding, but there is no
expectation that the transport system will return success/failure packets.
For UDP, any such has to be built into the application level protocol(s).
TCP, OTOH, /is/ a "connected" protocol expecting to receive ACK/NAK packets
for each one it sends out. If it doesn't receive either it will, after some
time-out period, declare a broken connection.


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/


More information about the Python-list mailing list