Spaces:
Running
Running
File size: 220 Bytes
b931367 |
1 2 3 4 5 6 7 8 9 10 |
import socket
def find_free_port():
"""
Finds a free port on the local machine.
"""
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(("", 0))
return s.getsockname()[1]
|