【发布时间】:2014-05-16 03:33:03
【问题描述】:
我有一个处理 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()。
有没有办法解决这个问题?
【问题讨论】: