WCF service endpoint localhost confusion

一曲冷凌霜 提交于 2019-12-10 13:17:04

问题


I'm confused as to why something works. I'm configuring a wcf service like this:

<services>
  <service name="ClientCommand" behaviorConfiguration="SomeServiceBehavior">
    <endpoint contract="IClientCommand" binding="netTcpBinding" BindingConfiguration="TcpPort" address="net.tcp://localhost:1304" />
  </service>
</services>

The BindingConfiguration and behaviorConfiguration are very simple, just configuring some timeouts.

In my exe, I start the host like this.

_serverHost = new ServiceHost(type); // implementing IClientCommand
_serverHost.Open();

It's all pretty simple and it works, I can call this service from a different pc. However, after reading up on a different issue (listening on tcp sockets), I get the impression it shouldn't work. As I'm binding to localhost the service should not be accessible from outside the pc it's running on?
I checked netstat on the pc and it did bind to ip address "0.0.0.0" instead of "127.0.0.1" explaining why it works from another pc.

But I don't get why it goes from localhost to "0.0.0.0"?


回答1:


Net.tcp is not restricted to communication on one machine, perhaps you are thinking on net.pipe? Regarding 0.0.0.0: How is the host file defined on the machine running the service? Here is a nice article on WCF in general.



来源:https://stackoverflow.com/questions/15428610/wcf-service-endpoint-localhost-confusion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!