Created
May 4, 2021 11:54
-
-
Save highfestiva/fde899d24e6ce37c115d3c3767f8b040 to your computer and use it in GitHub Desktop.
Check if a local TCP port is available
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import socket | |
import sys | |
host,port = sys.argv[1].split(':') | |
port = int(port) | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((host,port)) | |
s.listen(1) | |
s.close() | |
print('ok') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment