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() へのリモート呼び出しをいつ行ったかがわからないことです。
この問題を解決する方法はありますか?