小编Gre*_*sop的帖子

WCF服务端点localhost混淆

我很困惑为什么有些东西有效.我正在配置像这样的wcf服务:

<services>
  <service name="ClientCommand" behaviorConfiguration="SomeServiceBehavior">
    <endpoint contract="IClientCommand" binding="netTcpBinding" BindingConfiguration="TcpPort" address="net.tcp://localhost:1304" />
  </service>
</services>
Run Code Online (Sandbox Code Playgroud)

BindingConfiguration和behaviorConfiguration非常简单,只需配置一些超时.

在我的exe中,我像这样启动主机.

_serverHost = new ServiceHost(type); // implementing IClientCommand
_serverHost.Open();
Run Code Online (Sandbox Code Playgroud)

这一切都很简单,它可以工作,我可以从不同的电脑上调用这项服务.但是,在阅读了另一个问题(收听tcp套接字)后,我得到的印象是它不应该工作.因为我绑定到localhost,所以不应该从正在运行的pc外部访问该服务?
我在电脑上检查了netstat,它确实绑定到ip地址"0.0.0.0"而不是"127.0.0.1",解释了为什么它可以从另一台电脑上运行.

但我不明白为什么它从localhost变为"0.0.0.0"?

.net wcf localhost endpoint

6
推荐指数
1
解决办法
1507
查看次数

标签 统计

.net ×1

endpoint ×1

localhost ×1

wcf ×1