I'm using multiple self-hosted WCF services on the same machine. I need to open each of them on a different port (obviously), so I used "net:tcp://localhost:0" as address since I figured it would assign a free port this way.

Now I need to know which port was assigned actually. This code runs on the server, so I need the *local* port. How do I do that?