【发布时间】:2011-06-07 02:44:39
【问题描述】:
使用 127.0.0.1 和 localhost 有什么不同吗?
我问这个是因为我在定义 wcf 连接时注意到了一个不同之处。
<client>
<endpoint binding="netTcpBinding" bindingConfiguration="netTcpNosecurity" contract="MyClass" name="MyName" behaviorConfiguration="megaGraphBehavior" address="net.tcp://localhost:8011/myname" />
</client>
在某些环境中,我注意到服务器在使用 localhost 时突然开始抛出此错误,我只能通过使用 127.0.0.1 使其工作。
无法连接到 net.tcp://localhost:8011/myname。连接尝试持续了 00:00:02.2341176 的时间跨度。 TCP错误代码10061:无法建立连接,因为目标机器主动拒绝它127.0.0.1:8011。 ---> System.Net.Sockets.SocketException: No connection could be made because the target machine主动拒绝它127.0.0.1:8011
如何解释,我应该始终使用 127.0.0.1 吗?
【问题讨论】: