Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Network check...
#1
Need the codes...

I am looking for to check the network is up or down and/or check ping which quickly to check instead of waiting.

Because I do not want my code to pause of running while network is re-trying due the network is down.

thanks!
RAM
Reply
#2
see https://python-forum.io/Thread-Test-inte...connection
for a discussion of this.
Reply
#3
Thumbs Up perfectly! thanks!

Geez, I copied the code, actived is works but when I disconnected the network and it still said active. hummm...

I found one and works!

try:
    import httplib
except:
    import http.client as httplib

def have_internet():
    conn = httplib.HTTPConnection("www.google.com", timeout=5)
    try:
        conn.request("HEAD", "/")
        conn.close()
        print("actived")
        return True
    except:
        conn.close()
        print("inactived")
        return False

have_internet()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Check network WITHOUT use internet ATARI_LIVE 1 2,219 Oct-28-2020, 07:59 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020