views:

52

answers:

2

I'm interested in one WCF server exposing both HTTP and TCP interfaces. It'll be used with Silverlight clients, so the thinking is that the HTTP interface will be for secure communications while TCP will be used the rest of the time.

Is it possible for these two interfaces to use the same port in their endpoints, e.g. http://localhost:9000/ and net.tcp://localhost:9000/?

A: 

You can only have one "listener" on a TCP port, so unless the WCF server does some sort of protocol-level multiplexing (i.e. if it reads in an HTTP header, send it to the HTTP handler otherwise send it to the "raw" handler), you'll have to use different ports.

Of course the quickest way to find out is to configure your server with both of these interfaces and the same port, and check your logs for errors. Chances are each one will be attempting to bind to port 9000 from their own thread or process, and the second one will fail.

Marc Novakowski
A: 

No this is not possible. If you have the TCP port sharing service enabled, you can have multiple services listening on the same TCP port. Windows HTTP listener will also allow you to have multiple services sharing a common port (for example, a console application and IIS can both listen on port 80 at different URL's). But you can't use multiple bindings on the same port.

But I don't really see the advantage of doing that anyway. I would personally leave the HTTP endpoint on port 80 and of course your TCP endpoint is restricted to an upper port range. I'm not sure what scenario you're trying to enable though.

Josh Einstein