|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Detect TcpClient Connection droppedI 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 Jck,
A few years back I had the same issues. I never found a workaround with 1.0/1.1 framework. I ended up using 3rd party tool www.genuinechannels.com for my TcpClient. Cheers, Rob Panosh Jck wrote: Show quoteHide quote > 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 suggest using sockets for this. when one users ends the connection, your
informed in code. Also, you can check using properties to see if theres an active connection -- -iwdu15
1 Variable - 2 Forms
Co-existing ASP.NET 1.1 and 2.0??? Accessing Structure Members Communication between threads Transactions through Remoting Simple xpath question Function doesn't return a value on all code paths surpress newline on Enter press Excel already runnig, how to update with VB Moving windows |
|||||||||||||||||||||||