开发者

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

开发者 https://www.devze.com 2022-12-10 18:28 出处:网络
I have a WCF service that uses the NetTcpBinding and is running within a Windows service. Remote clients connect to this service. 开发者_JS百科So far, I have defined the endpoint to use \"localhost\".

I have a WCF service that uses the NetTcpBinding and is running within a Windows service. Remote clients connect to this service. 开发者_JS百科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?


You can use System.Environment.MachineName

For example:

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号