use checking read() == -1 to detect whether client shut down instead of
pinging