Automatically listen to a free port and output the port number.