Hello,
I did an archive search and found a post that indicated that what I describe
below is known behaviour. The question is: why does this occur on Linux?
According to SUSv3, if we perform a shutdown(fd, SHUT_RD) on a socket, then
further reads on that socket should be disabled. In the AF_UNIX domain, all
is fine - things operate as expected. However, for stream sockets, things
are different (tested on 2.2.14, and 2.4.19):
1. If we perform a read() on the socket and there is no data, then 0 (EOF)
is (immediately) returned. (This is expected.)
2. However, the peer can still write() to the socket, and afterwards we can
read() that data from the socket, even though the reading half of the socket
should be shutdown. Instead of this behaviour, I expected the data to be
discarded, and the read() to return 0 as in point 1.
I've read the relevant source code to confirm the anomalous behaviour in
point 2. The question is: why do things happen in this way on Linux?
Thansk
Michael