Sidebar Ad

Categories

Python : Program To Detect Computer Is Connected To Internet Or Not

 

In this post we will learn how to make a python program that detect the internet connection

Code :

 

import socket
findhost=socket.gethostbyname(socket.gethostname())
if findhost=="127.0.0.1":
#Detecting Localhost
    
    print("No Internet Connection")
else:
    print("Internet Connection Exist")

Output :
If Internet Connection Exist , It Will Print Text “Internet Connection Exist” Otherwise It Will Show “No Internet Connection”

11

App ID

I'm Tech Expert, Programmer , Web Developer, Owner Of this site and much more 😁

    Leave Your Comment

    Your email address will not be published.*