Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When creating a WCF Service with NetTcpBinding, use endpoint "localhost" or machine's host name?

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?

like image 855
Elan Avatar asked Nov 21 '25 14:11

Elan


1 Answers

You can use System.Environment.MachineName

For example:

new EndpointAddress(new UriBuilder {Scheme = Uri.UriSchemeNetTcp, Port = port, Host = System.Environment.MachineName}.Uri);
like image 163
flayn Avatar answered Nov 24 '25 08:11

flayn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!