You can start by using one port, keeping it in a variable and then, upon a successful connection, create a new listener on another port!
Also, to liberate used ports, check if a port is not used for a while, like a few hours, and if so, re-initialize it!