使用 NetTcpBinding 创建 WCF 服务时,请使用端点“localhost”或机器的主机名?
我有一个使用 NetTcpBinding 并在 Windows 服务中运行的 WCF 服务。远程客户端连接到此服务。到目前为止,我已经定义了使用“localhost”的端点。
如果主机有多个网络适配器,它会在所有适配器上接收消息吗?
将计算机的主机名分配给端点而不是“localhost”会更好吗?
有什么优点/缺点?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以使用
System.Environment.MachineName
例如:
You can use
System.Environment.MachineName
For example:
如果我希望客户端能够连接到任何外部接口以及本地主机,我通常将 URI 设置为:
net.tcp://0.0.0.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.