On Mon, 7 Feb 2022 at 20:18, Abdur-Rahmaan Janhangeer <arj.pyt...@gmail.com> wrote: > > Greetings, > > Using the standard library or 3rd party libraries, what's the > best way to check if there is internet? Checking if google.com > is reachable is good but I wonder if there is a more native, > protocol-oriented > way of knowing? >
What do you mean by "if there is internet"? How low a level of connection do you want to test? You could ping an IP address that you know and can guarantee will respond. You could attempt a DNS lookup. You could try an HTTP request. Each one can fail in different ways, for different reasons. It's best to test what you actually care about. > Even this URL recommends checking if a domain is up as a way to check for > internet connectivity: > https://www.ibm.com/support/pages/checking-network-connectivity-when-using-python-and-ibm-resilient-circuits That talks about a misconfigured proxy as being the most likely cause. Is that something you're trying to test for? There is no single concept of "there is internet". (Other than, in a trivial sense, that the internet does exist.) What you need to know is "can I use the internet?", and ultimately, that depends on what you need it to do. ChrisA -- https://mail.python.org/mailman/listinfo/python-list