By closed connection I mean that the other end closed it gracefully.
I would expect to receive a 0 from the
write() as returned value, but please correct me if I am wrong.
Exact behavior may depend on underlying OS but in general you should get an error, i.e.,
write will return
-1 and set
ECONNRESET for instance).
EPIPE. On a more modern Linux box I get the same thing. This is because it takes one extra TCP round-trip for the sender to "see" that the receiver has gone away. Setting
SO_KEEPALIVEshould cause an earlier discovery but it can take a long time (RFC-1122 says at least 2 hours!) - torek 2012-04-04 07:43