import socket


def get_free_tcp_port() -> int:
    """
    get free tcp port in dynamic port range
    which is defined by IANA
    cf. https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml

    :returns: free port number
    """
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        s.bind(('', 0))
        _address, port = s.getsockname()
        return port