import socket


def get_next_open_port(ip, port):
    """Returns the next open port for the given IP address starting at port"""
    found = False
    while True:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            s.bind((ip, port))
            found = True
        except:
            port += 1
        finally:
            s.close()
        if found:
            break
    print('next open port ->', port)
    return port