j avais tout a l'heure le meme probleme que toi voici la solution qui marche a 100% :
tu utilise la fonction select qui peut prendre un timeout voici le code qui peut regler l 'affaire:
fd_set input_set, exc_set; // Create Input set
int s;
timeval timeout;
timeout.tv_sec = 2; // Attends 2 sec pour returner.
timeout.tv_usec = 0;
while (1){
//Set up the input,and exception sets for select().
FD_ZERO(&input_set);
FD_SET(m_Socket, &input_set);
s = select(0 /* vive le c-unix */, &input_set, NULL, NULL,&timeout);
if (s > 0) // Is there data coming in?
{
// tu fais un recv.
}
if (s == SOCKET_ERROR)
{
OutputDebugString("SOCKET_ERROR");
break;
}
if (s == 0)
OutputDebugString("no Data coming in");
}