示例#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
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