Since we can't close a connection for writing only (can we?), I think both
error codes (ECONNRESET and EPIPE) are correct. So it's up to us to decide
which one we want to use. Since ERR_RST is only used with tcp, defining
ERR_RST to EPIPE should do the trick. (Or is EPIPE also returned to UDP
sockets when an icmp-packet 'dest unreachable' was received for that udp
port? I don't think we support that).
[bug #9455] The sockets API does not correctly inform a process that a RST has been received
Follow-up Comment #4, bug #9455 (project lwip):
Frederic's point was that sockets.c already returns ECONNRESET for ERR_RST.
As far as I know, this is what all other systems do in the same situation,
and so is a better error code than EPIPE.
As far as I can tell, send/write use netconn_write, which will return
conn->err if it isn't ERR_OK. So ERR_RST should be returned, causing
ECONNRESET to in turn be returned. I admit I haven't tried experimenting.
BTW, I believe EPIPE is when the local end has been closed.