> Hello,
>
> I've the following problem.
> If the peer has closed its socket connection the second write to this
> socket should return -1 and errno should be set to EPIPE (if SIGPIPE is
> set
> to be ignored). This never happens with my code. Why?
>
So what errno does it return? Writing to a closed socket can
return several things, based upon what was detected first. I
don't think you can count on a specific errno value. Successful
socket handlers use the following heuristics:
If the returned value was -1, the error is temporary, try again.
If the returned value was 0, the error is permanent.
The first write to a closed socket may return -1, with an errno
of something representative of local buffers being full. It takes
some time for a FIN or a RST to show up as the reason why there
is so much data queued. So, if you follow the above heuristic,
the last reason why you got the previous errors will likely be
what you expect.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).
"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/