Skip to content

Instantly share code, notes, and snippets.

@kgantsov
Created March 28, 2018 09:30
Show Gist options
  • Save kgantsov/4257a591602696347b0aa7e12f3e0151 to your computer and use it in GitHub Desktop.
Save kgantsov/4257a591602696347b0aa7e12f3e0151 to your computer and use it in GitHub Desktop.
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('127.0.0.1', 8000))
sock.close()
if result == 0:
print("Port: 8000 is already in use")
else:
print("Port is ready")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment