首页 > 解决方案 > 客户端断开连接时从 TCP/IP 服务器引发的错误

问题描述

我将以下代码作为 TCP/IP 服务器的一部分。该程序运行良好,但我注意到 System.IO.IOException 错误Server作为Client断开连接抛出。(我实际上是在断开客户端的连接。)

Private Sub ReadAllClient()
    Try
        RaiseEvent getMessage(New StreamReader(listClient.GetStream).ReadLine)
        listClient.GetStream.BeginRead(New Byte() {0}, 0, 0, New AsyncCallback(AddressOf ReadAllClient), Nothing)
    Catch ex As Exception
        RaiseEvent clientLogout(Me)
    End Try
End Sub

(编辑:错误消息详细信息)

System.IO.IOException: 'Unable to read data from the transport 
connection: An established connection was aborted by the software in 
your host machine.'

此错误通常不是 VS 2017 的一部分,只是将其抛出以查找原因,它就是这个 Try/Catch 语句。(Catch 部分肯定在工作......但正在抛出错误。)

我应该担心这个异常被抛出吗?或者它是否足够安全而可以忽略?

标签: vb.nettcplistener

解决方案


推荐阅读