Hi there. I'm writing a tool, which must detect is connection was terminated on remote side.
Every action on network, I'm fetching with select(). And I want in some place check if connection still active.
There are code:
How to do it in my code?
Every action on network, I'm fetching with select(). And I want in some place check if connection still active.
There are code:
Code:
while (1)
{
tv.tv_sec = 1;
tv.tv_usec = 0;
FD_ZERO (&readfds);
FD_SET (priv->socket, &readfds);
rc = select (priv->socket+1, &readfds, NULL, NULL, &tv);
if (rc<0)
{
/* error of using select() */
}
else if (rc==0)
{
/* timeout */
}
else
{
/* HERE I can read data */
}
/* and HERE I want to check if connection still active*/
}