我有一个处理 TcpClients 的类。班级应该做的是:
while the other end has not done a graceful close or we are stopping
{
receive a request
process it
send response
}
因为我不知道其他客户端何时会发送请求,所以我无法在设置超时的情况下进行读取,所以到目前为止我所拥有的是:
While Not Me.Stopping()
Try
If tcpClient.Available >= My.Settings.minimumModBusTcpFrameSize Then
processer = New MessageProcesser(Me, tcpClient)
processer.ProcessMessage()
End If
Catch ex As TimeoutException
''#Do not nothing, the current message will timeout on origin too.
End Try
End While
这种方法的问题是我永远不知道客户端何时对 Close() 进行了远程调用。
有没有办法解决这个问题?