G
Guest
Could someone tell me how to detect TcpClient connection dropped, please?
I have a TcpClient connected to a server by IP and Port. The TcpClient only
read data from the server. However, if there is no data received from the
server for a period of time, I am unable to determine whether the connection
is dropped or simply no data is sent from the server.
Work around:
Currently, I am trying to send data with 0 length to detect the connection.
But I want to have a proper way to do it. Please help!
While True
Try
myTcpClient.GetStream().Write(MySendBuffer, 0, 0)
Catch ex As Exception
' Assume connection dropped
Exit While
End Try
Application.DoEvents()
End While
I have a TcpClient connected to a server by IP and Port. The TcpClient only
read data from the server. However, if there is no data received from the
server for a period of time, I am unable to determine whether the connection
is dropped or simply no data is sent from the server.
Work around:
Currently, I am trying to send data with 0 length to detect the connection.
But I want to have a proper way to do it. Please help!
While True
Try
myTcpClient.GetStream().Write(MySendBuffer, 0, 0)
Catch ex As Exception
' Assume connection dropped
Exit While
End Try
Application.DoEvents()
End While