Ian Ringrose
Ian Ringrose

Reputation: 51917

Can a WCF server expose more than one service over the same TCP port?

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)

Upvotes: 0

Views: 534

Answers (3)

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65391

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.

Upvotes: 1

MattC
MattC

Reputation: 4004

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.

Upvotes: 0

Benny
Benny

Reputation: 8815

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.

Upvotes: 0

Related Questions