R – When creating a WCF Service with NetTcpBinding, use endpoint “localhost” or machine’s host name

endpointlocalhostnettcpbindingwcfwindows-services

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?

Best Answer

You can use System.Environment.MachineName

For example:

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