I'm having a little trouble using sockets in a Perl server.
How can you know a (non-blocking) client just disconnected ? In C, I'm used to doing
if (recv(sock, buff, size, flags) == 0) {
printf("Client disconnected\n";
}
or the equivalent in python or other languages : recv
returns -1 if no data is available, 0 if client exited, a positive number if data could be read.
But perl's recv
doesn't work this way, and using $data = <$sock>
does not seem to give any possibility to know.
Is there any (simple) possibility ?