import random


def gen_port(num=1):
    """
        Generate a port number or a list
    """
    ports_list = [random.randrange(10000, 60000) for x in range(num)]
    if num == 1:
        # s.bind((Network.get_ip(4), 0)) is enough
        return ports_list[0]
    else:
        return ports_list