INNER CODE UNIT · Python

find_free_port

OschAI/VisioFirm · run.py:12

def find_free_port(start_port=8000):
    port = start_port
    while True:
        with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
            try:
                s.bind(('', port))
                return port
            except OSError:
                port += 1 

def main():
    # Handle version flags
    if any(arg in ('-V', '--version') for arg in sys.argv[1:]):
        print(f"VisioFirm v{visiofirm.__version__}")
        return

    port = find_free_port()
    url = f"http://localhost:{port}"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…