#!/usr/bin/env python3
"""Print an OS-selected free localhost TCP port for shell specs."""

import socket

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
    sock.bind(("127.0.0.1", 0))
    print(sock.getsockname()[1])
