When I call recv() or send() from IO::Socket, how can I determine if the remote end has crashed or the connection is broken (ie broken pipe)? When I check the return value, it always return a null string:
while (defined $client_socket->recv($data, 1024)) {
+ ### always true even if the remote end has crashed
print "received data: $data\n";
}