Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"You are WRONG, you ol' brass-breasted fascist poop!" -- Bloom County


devel / comp.lang.python / Re: Best way to check if there is internet?

SubjectAuthor
o Re: Best way to check if there is internet?Chris Angelico

1
Re: Best way to check if there is internet?

<mailman.25.1644226082.7010.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16926&group=comp.lang.python#16926

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Best way to check if there is internet?
Date: Mon, 7 Feb 2022 20:27:51 +1100
Lines: 31
Message-ID: <mailman.25.1644226082.7010.python-list@python.org>
References: <CADrxXXmDuGo7-JmpeEwSpecL9BO-K_umudE7hOCcyC+V78UqJA@mail.gmail.com>
<CAPTjJmog2LaVSqLX=6C2azDw_ngTMKkVaiVPPWBHq9g4DXpcNg@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 9XTHGbNnc9hjG+2EyWdu3wLS3Fyzp7GKXJjVBGopL7Og==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=Dfk3CNBQ;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.055
X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; '2022': 0.05;
'url:support': 0.05; 'http': 0.07; 'dns': 0.09; 'trivial': 0.09;
'talks': 0.14; '"there': 0.16; 'cause.': 0.16; 'chrisa': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'google.com': 0.16; 'janhangeer': 0.16; 'lookup.': 0.16; 'ping':
0.16; 'subject:way': 0.16; 'wrote:': 0.16; 'feb': 0.17; 'url':
0.19; 'to:addr:python-list': 0.20; "what's": 0.22; 'depends':
0.25; 'library': 0.26; 'party': 0.26; 'request.': 0.28; 'attempt':
0.31; 'concept': 0.32; 'do.': 0.32; 'subject:there': 0.32;
'to:name:python': 0.32; 'message-id:@mail.gmail.com': 0.32; 'but':
0.32; 'there': 0.33; 'mean': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'trying': 0.35; '"if': 0.35;
'from:addr:gmail.com': 0.35; 'mon,': 0.36; 'using': 0.37; "it's":
0.37; 'received:209.85': 0.37; 'way': 0.38; 'could': 0.38;
'received:209': 0.39; 'single': 0.39; 'use': 0.39; 'something':
0.40; 'want': 0.40; 'try': 0.40; 'best': 0.61; 'connection': 0.61;
'likely': 0.61; 'about.': 0.64; 'respond.': 0.69; 'subject:check':
0.69; 'url-ip:23.34/16': 0.69; 'care': 0.71; 'low': 0.74;
'guarantee': 0.76; 'domain': 0.77; 'greetings,': 0.80; '3rd':
0.81; '(other': 0.84; 'internet?': 0.84; 'url-
ip:23.34.185.132/32': 0.84; 'url-ip:23.34.185/24': 0.84;
'url:ibm': 0.84; 'url:pages': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=IXPEm/At0H8bfR8agr5p0XUa9a9EG13guYO2j7EVjfc=;
b=Dfk3CNBQ/JychZh2kmxwQX/PaouGoycqOYTFTyIKWKFZ/RE8/aKnpTCz9G5XzN6grC
zIAqGE0/19PNAGur5WdWjIUHGgREywDoVG1w1ZAMuyv84Xdw2+sKlle0xdRJlE3hiYjg
QZw2QQ+ELduAQtbvy/UmE5gXHnSwEfrjHF5d1FE07LslWfzNewNoL8qcoKBWsg05SiCg
bjQozamDu5LelTQ2PAiwp/GfMCVlvER146ZWPHHSIWQi8tph5rmTs9nX1rQB3SVPpiPp
HuMSgAloKyNRe3LVrt30GBmkmay1NhwlOMB80Vh/6xxv1laYMEXQbEGYlwgzK2eNGk2R
RM2Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=IXPEm/At0H8bfR8agr5p0XUa9a9EG13guYO2j7EVjfc=;
b=TNT1UrSYb+Mry79ec0OBCVJTENwt8MSfUAguTLgr9MbRBFbQHu6G5+g5m4oUelSznE
/fJkP5NNQzwB/RFiLMRKwyaeoiqRTCNBkDEvApQDIBkickoL2zIylcXPWlwci7IkxT6E
qwGiy0wVzWvkOBoy4aweip3jhtljtQfgddXEqc8wvIZeIRfB5e3r/bwccLSozL59hxbG
MwE5neITNeoOyv1Zh3lfvcpnX0cXuOf8cafBUssW5DNQw88eL1wyfS48iQdTFk+6Gg2F
vgCfOQIDRBHQOHb2IomDwKUXJYeNjqUQuo7x0IG9GnG3VfXugG1DccwduszydBkpXAEx
H8zg==
X-Gm-Message-State: AOAM5301FK1oVId8VsXGILUurPXqlqkaIkvpuvzFAKyNNosOCEi4jfRk
xP+R576fpdkKQm9m/U9TksU5wF+RHjvZWzy5PsdVyNBKT6o=
X-Google-Smtp-Source: ABdhPJxvPGSMO1TydwypRhQpqb4jUmIamgcRDNT8szsuJYdoB8VHl8P3Sbfan9wqFNQttxxp2XQalatGYJXpOSTWKMo=
X-Received: by 2002:adf:fecf:: with SMTP id q15mr2199109wrs.104.1644226081889;
Mon, 07 Feb 2022 01:28:01 -0800 (PST)
In-Reply-To: <CADrxXXmDuGo7-JmpeEwSpecL9BO-K_umudE7hOCcyC+V78UqJA@mail.gmail.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmog2LaVSqLX=6C2azDw_ngTMKkVaiVPPWBHq9g4DXpcNg@mail.gmail.com>
X-Mailman-Original-References: <CADrxXXmDuGo7-JmpeEwSpecL9BO-K_umudE7hOCcyC+V78UqJA@mail.gmail.com>
 by: Chris Angelico - Mon, 7 Feb 2022 09:27 UTC

On Mon, 7 Feb 2022 at 20:18, Abdur-Rahmaan Janhangeer
<arj.python@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

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor