为什么TCP发送超时似乎未连接任何东西?

问题描述

使用代码

Dim client As New System.Net.sockets.TcpClient()
client.ReceiveTimeout = 250
client.SendTimeout = 250
client.Connect(New System.Net.IPEndPoint(New System.Net.IPAddress({***,***,***}),*****))
Assert.IsTrue(client.GetStream.CanTimeout)

Try
  While True
    Dim sent As Integer = client.Client.Send({0})
    System.Threading.Thread.Sleep(100)
    ' Cable is physically disconnected while this loop is active.
  End While
Catch ex As Exception
End Try

循环需要18秒才能意识到硬断开。如果超时为250毫秒,怎么可能需要这么长时间?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)