tags:

views:

19

answers:

1

Hi,

I have two processes running on the same machine. Each process is hosting a WCF service to allow inter process communications asynchronously. As of now, I have assigned a fixed port 8731 and 9000 to the two wcf services. What if a customer machine has these ports taken up? How can i dynamically make the wcf client find the wcf service if I were to dynamically allocate an available port?

Thanks for your help in advance.

+1  A: 

I assume you're creating services in code. If you're afraid of the client not having those ports available, you should configure your endpoints using app.config. That way, if a client has an issue with a port, you can simply change their config file instead of recompiling your code.

Will
+1 config is the way to go.
marc_s
Is there a way to do detect and change this automatically in code and the update the app.config with the available ports to use?
Subbu
@subbu Sure. If you can read minds.WCF allows you to open any endpoint you want (as long as security on the box will let you). I'm in a similar situation--how do I allow people to define an endpoint without requiring them to edit app.config. I determined there was no way other other than convention-no compile time safety. It stinks, but as long as I make it obvious via documentation and prevent the user from making a mistake at the earliest possible moment, I make the "pit of success" as big as I can. In my case, when dealing with WF, I don't have a choice. You might have more, depending.
Will