Hello,
This can be simply done by using a single "Check TCP port" custom action. Then on each of your dialog you should implement the approach exposed on our
"How to check if a TCP port is free by using a custom action" tutorial.
All the best,
Daniel