If the socket is closed by the peer, the write(...) generates a SIGPIPE, which
crashes the program. I am now explicitly making the socket to ignore SIGPIPE,
which eventually leads to an EPIPE error, which I handle locally. I also
break out of the pump loop for the socket that generates a broken pipe error.
Additionally read(…) and write(…) can also return -1 on error, which I guess
we should not add up in ep->rcvd and ep->send counters. I also now close the
socket once the pump loop is over to not leave the state until the end.