views:

405

answers:

3

I have a WCF service that uses the NetTcpBinding and is running within a Windows service. Remote clients connect to this service. So far, I have defined the endpoint to use "localhost".

If the host machine has multiple network adapters, will it receive messages on all adapters?

Would it be better to assign the machine's host name to the endpoint instead of "localhost"?

What are the advantages/disadvantages?

A: 

I personally have allays defined the endpoint using the name of the machine. However, clients that run on the machine can still connect using localhost I will have to test the multiple interface question. I would assume that whatever IP you have for the name is what will get the message but i'm not sure.

rerun
A: 

If I want clients to be able to connect on any external interface as well as from localhost, I usually set the URI up as:

net.tcp://0.0.0.0

This also eases the burden of deploying to multiple machines, because you don't need to go and change the hostname on every machine, but there might be security implications in allowing this in your environment.

Terence Lewis
+1  A: 

You can use System.Environment.MachineName

For example:

new EndpointAddress(new UriBuilder {Scheme = Uri.UriSchemeNetTcp, Port = port, Host = System.Environment.MachineName}.Uri);
Flo