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?

1
  • I need the answer to this exact same question. Perhaps @marc_s can help out?
    – Matt Davis
    Commented Nov 9, 2009 at 22:54

2 Answers 2

1

You can use System.Environment.MachineName

For example:

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

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.