tags:

views:

45

answers:

3

Can I expose more than one WCF service (interface) over the same port and have a single client connect to both services with different TCP connections?

I need the two services to be independent of each other, so that the response to an outstanding message on the channel to one service does not get blocked by a call-back from the other service. (Some client)

A: 

I think the answer is yes, as long as the Address is different, I meant after the same base address you append different subaddress. not sure about my answer.

Benny
A: 

I'm pretty sure not, once a host is listening on a port, it owns it.Hosting in IIS with WAS would allow multiple services, on a single web server, to be reached via a DNS name and host headers.

MattC
+1  A: 

On the server side there is no problem exposing several WCF interfaces on the same port. For example in IIS you could have 100's of svc files each with it's own interface, on the same port.

On the client side you can create 2 WCF clients, each with it's own channel.

The only problem I see is that you need to be carefull that the second channel does not go out of scope, when the first callback comes in. If the channel goes out of scope, it gets closed, and then the callback has nothing to callback to.

You could also try putting each of the calls on their own thread.

Shiraz Bhaiji
But in IIS case there is still only one host listening, the .NETPortSharingService does the listening for non HTTP calls then routes to IIS and the rest is by IIS direct on the port (usually 80) that the web servers is on.What about a self host service, I'm not sure you can have two on the same port, it's basic sockets right?
MattC
You can have a single self host service on a port, but the configuration of that self host can have many WCF interfaces in it, each on their own address.
Shiraz Bhaiji