updated skeleton with true data
This commit is contained in:
@ -1,2 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
print(8000)
|
||||
import socket
|
||||
|
||||
START, END = 8000, 8100
|
||||
|
||||
def port_free(port):
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
try:
|
||||
s.bind(("0.0.0.0", port))
|
||||
return True
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
for port in range(START, END + 1):
|
||||
if port_free(port):
|
||||
print(port)
|
||||
exit(0)
|
||||
|
||||
print("ERR_NO_FREE_PORT")
|
||||
exit(1)
|
||||
|
||||
Reference in New Issue
Block a user