Creating a binding with a dynamically assigned port

Is it possible to create a binding for a service such that the operating system assigns an available port to it (similar to the way the socket APIs treat the port value 0).


Answer this question

Creating a binding with a dynamically assigned port

  • Ceres

    A service needs to have a well known address for the clients to connect to it (more below). The client will choose a random port to talk to the service's port.

    A well known address means a unique URI. WCF has a port-sharing feature that allows multiple services to listen on the same TCP port. This is very similar to the ability to have multiple Web applications listening on port 80. In practice, WCF has a listener that your application (automatically) registers with and that listener now handles the actual socket communication. Your application will get the messages destined to it. The address format you use with the port sharing feature is "net.tcp://<machine name>/some/unique/path". As you may notice, there's no indication of the specific port to use, and 2 or more services can listen on this same "no port" address as long as the URIs are different.

    Does this address your needs


  • Creating a binding with a dynamically assigned port