예제 #1
0
파일: base.py 프로젝트: smendes/HTTPretty
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
예제 #2
0
파일: base.py 프로젝트: HTTPretty/HTTPretty
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