0

当 Windows.Networking.Sockets.StreamSocket 类的 ConnectAsync 方法失败时,我得到 2 类错误。

“连接尝试失败,因为连接方在一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应。”

或者

“无法建立连接,因为目标机器主动拒绝它”

这两个错误都是随机发生的,因此我无法弄清楚两者之间的区别。这些之间的技术区别是什么?

4

1 回答 1

2
  • The former usually means that the target machine is inaccessible (e.g. it's off, or your internet connection is down, etc.)
  • The latter means the machine has been reached, but the TCP port is not open (usually it means that the server program is not running; there is no socket listening on it).

Note that if the target machine is running a firewall application that blocks this port, it's usually configured to pretend the machine is inaccessible (by silently dropping all connection requests) instead of actively refusing the connection.

于 2013-10-09T07:52:50.690 回答