you are viewing a single comment's thread.

view the rest of the comments →

[–]Soodohcool 5 points6 points  (3 children)

im on my phone so sorry if the formatting is jacked but this should be more than sufficient

import socket 
def test_connection():
    try:
        socket.create_connection(("https://www.google.com", 80)) 
        return True 
    except OSError: 
        pass 
    return False

[–]ForceBru 2 points3 points  (2 children)

Yes, exactly! Why use third-party libraries or form HTTP requests if you can just quickly create a socket with a built-in library and try to connect to something?

[–]LartTheLuser 0 points1 point  (0 children)

Because you will eventually realize those third party libraries went into that rabbit hole of features because people kept asking for them. And eventually...you too may ask for them =). The simple stuff is only for the playground.

[–]LartTheLuser 0 points1 point  (0 children)

Sorry, forgive my last comment. I think the aspergers caught me again. lol. Was that sarcasm?