What can cause a spontaneous EPIPE error without either end calling close() or crashing?
Perhaps you could try strace as described in: http://modperlbook.org/html/6-9-1-Detecting-Aborted-Connections.html
I assume that your problem is related to the one described here: http://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable
Unfortunately I'm having a similar problem myself but couldn't manage to get it fixed with the given advices. However, perhaps that SO_LINGER thing works for you.
shutdown()
may have been called on one of thesocket endpoints.If either side may fork and execute achild process, ensure that the
FD_CLOEXEC
(close-on-exec) flag is set on thesocket file descriptor if you did notintend for it to be inherited by thechild. Otherwise the child processcould (accidentally or otherwise) bemanipulating your socket connection.
I would also check that there's no sneaky firewall in the middle. It's possible an intermediate forwarding node on the route sends an RST
. The best way to track that down is of course the packet sniffer (or its GUI cousin.)