I was looking for a way to set timeout for one connection and I've already found some very good answers, but timeout alone isn't enough for me.
I want my last server -> client message to be an announcement about timeout. I don't want to suddenly interrupt connection with client leaving them clueless.
What I'm looking for:
if ( /* should timeout now */ )
{
char timeout_msg [] = "Connection timed out";
if (send(sock_fd, timeout_msg, sizeof(timeout_msg), 0) < 0)
{
perror("Sending problem");
return whatever;
}
//actually time out now
}
Aucun commentaire:
Enregistrer un commentaire