Ejemplo n.º 1
0
def get_free_tcp_port():
    """returns a TCP port that can be used for listen in the host.
    """
    tcp = old_socket(socket.AF_INET, socket.SOCK_STREAM)
    tcp.bind(('', 0))
    host, port = tcp.getsockname()
    tcp.close()
    return port
Ejemplo n.º 2
0
def get_free_tcp_port():
    """returns a TCP port that can be used for listen in the host.
    """
    tcp = old_socket(socket.AF_INET, socket.SOCK_STREAM)
    tcp.bind(('', 0))
    host, port = tcp.getsockname()
    tcp.close()
    return port