(ip)
Return a port available for listening on the given `ip`.
Return a port available for listening on the given `ip`.
Return a port available for listening on the given ip .
def find_free_port(ip):
    """Return a port available for listening on the given `ip`."""
    with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
        s.bind((ip, 0))
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        return s.getsockname()[1]
def find_free_port ( ip ) : with closing ( socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) ) as s : s . bind ( ( ip , 0 ) ) s . setsockopt ( socket . SOL_SOCKET , socket . SO_REUSEADDR , 1 ) return s . getsockname ( ) [ 1 ]