Skip to content

Instantly share code, notes, and snippets.

@giorgiberia
Created April 13, 2021 08:40
Show Gist options
  • Save giorgiberia/814fdc99586f6133c85148aa3f013b1f to your computer and use it in GitHub Desktop.
Save giorgiberia/814fdc99586f6133c85148aa3f013b1f to your computer and use it in GitHub Desktop.
import socket
a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = 9000
location = ("127.0.0.1", port)
result_of_check = a_socket.connect_ex(location)
print(str(port)+" open" if result_of_check == 0 else str(port)+" not open")
a_socket.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment