Thx for the good replies, helped me find the explanation I was looking for:
http://lkml.org/lkml/2002/6/10/68.
Basically it's a implementation dispute, where one implementation exists on Linux and another on "Other UNIX".
Here are some citations from the discussions in the above mentioned thread:
"The problem stems from the fact that Linux does not make distinction between 'not yet connected' and 'already closed' states.
What you say is true and correct for 'already closed' state. In this case
select _must_ return 'ready to read' at least once so that application can
properly sense EOF condition. What happens on subsequent select's/read's is
strictly speaking implementation defined (access to a file after EOF has
been seen is undefined) but
natural implementation is "sticky EOF" that
always returns EOF after socket has been closed."
Example output from a test application:
"Linux runs:
bor@cooker% ./a.out
testing with a normal, unconnected socket:
socket is readable
socket is writeable
created socket, select() returned 2
read() returned 0, errno = 0 (Success)
write() returned -1, errno = 32 (Broken pipe)
testing with a non-blocking, unconnected socket:
socket is readable
socket is writeable
socket nonblocking, select() returned 2
read() returned 0, errno = 0 (Success)
write() returned -1, errno = 32 (Broken pipe)
"Other UNIX" runs:
bor@itsrm2% /tmp/a.out
testing with a normal, unconnected socket:
created socket, select() returned 0
read() returned -1, errno = 134 (Transport endpoint is not connected)
write() returned -1, errno = 134 (Transport endpoint is not connected)
testing with a non-blocking, unconnected socket:
socket nonblocking, select() returned 0
read() returned -1, errno = 134 (Transport endpoint is not connected)
write() returned -1, errno = 134 (Transport endpoint is not connected)"