mardi 2 janvier 2018

TCP recv() function behavior in a loop in a program?

I have a TCP connection active with socket being created with TCP_KEEPALIVE parameter.

Now,

While(1)
{
   int n = ::recv(socketId,buff,BUF_SIZE,MSG_WAITALL);
   if ( n > 0)
   {
     // do something
   }
}  

Now lets say, if I don't receive data at socketId for sometime lets say 2-3 minutes ? what will happen ? will the program keep waiting at recv() ?

While doing this, I observed that the my program stopped after some time when I stopped receiving data on the socket : socketId.

My program did not create any core dump file, No sign of crashing or anything. So can someone explain why the program/process stopped ?

Aucun commentaire:

Enregistrer un commentaire