Added the get_next_open_port function.