Detecting a broken TCP connection, which was not closed
Posted: Sat Nov 22, 2008 8:00 am
Once I make a TCP connection to another board and lets say the remote end either looses power or unplugs the Ethernet cable, I need to be able to detect that the connection is gone and not just sit there in the do while loop of
do
{
n = ReadWithTimeout( tcp_fd[LINE1], RC_Buffer, RC_BUFSIZE, 5);
}while(n >=0);
Because when the connection is dropped in the manner described this ReadWithTimeout does not produce the -1 like I would expect if connection terminated.
do
{
n = ReadWithTimeout( tcp_fd[LINE1], RC_Buffer, RC_BUFSIZE, 5);
}while(n >=0);
Because when the connection is dropped in the manner described this ReadWithTimeout does not produce the -1 like I would expect if connection terminated.