def METHOD_NAME(addr, port):
    # Get address info list.
    addr_infos = socket.getaddrinfo(addr, port)
    for (addr_family, addr_type, _, _, sock_addr) in addr_infos:
        # Filter so we only attempt to bind IPV4/6 TCP addresses.
        if addr_family != socket.AF_INET and addr_family != socket.AF_INET6:
            continue
        if addr_type != socket.SOCK_STREAM:
            continue
        # Print address info.
        addr_family_str = "ipv4" if (addr_family == socket.AF_INET) else "ipv6"
        print("Bind %s: %s port %d" % (addr_family_str, sock_addr[0], port))
        # Attempt to bind socket.
        sock = socket.socket(addr_family, addr_type)
        while True:
            try:
                sock.bind(sock_addr)
                sock.close()
                print("Bind success.")
                break
            except socket.error as e:
                print("Bind failed. Error: " + str(e) + ". Retrying.")
                time.sleep(1)