D
Droopy
Hi,
I developed an application in C# (VS 2003) using Tcp sockets.
What is the more reliable way to know when a Tcp connection is broken.
My code looks like this :
while (_mustRun)
{
if (_socket.Poll (PollTimeout, SelectMode.SelectRead))
{
if (_socket.Available == 0)
{
// connection closed or failed
break;
}
if (_socket.Available >= needed bytes)
{
_socket.Receive (...)
}
}
}
I am using "Poll" because I want to be able to stop my thread by simply
setting my "_mustRun" boolean variable instead of aborting the thread.
It seems to work (when the peer application is closed or killed) but not
when the "peer host" is brutally shutdown (by removing power cable for
example).
Thanks in advance for your help.
Droopy.
I developed an application in C# (VS 2003) using Tcp sockets.
What is the more reliable way to know when a Tcp connection is broken.
My code looks like this :
while (_mustRun)
{
if (_socket.Poll (PollTimeout, SelectMode.SelectRead))
{
if (_socket.Available == 0)
{
// connection closed or failed
break;
}
if (_socket.Available >= needed bytes)
{
_socket.Receive (...)
}
}
}
I am using "Poll" because I want to be able to stop my thread by simply
setting my "_mustRun" boolean variable instead of aborting the thread.
It seems to work (when the peer application is closed or killed) but not
when the "peer host" is brutally shutdown (by removing power cable for
example).
Thanks in advance for your help.
Droopy.