* shutdown() and SHUT_RD on TCP sockets - anomalous behaviour?
@ 2002-10-24 12:21 Michael Kerrisk
0 siblings, 0 replies; only message in thread
From: Michael Kerrisk @ 2002-10-24 12:21 UTC (permalink / raw)
To: linux-kernel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-10-24 12:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-24 12:21 shutdown() and SHUT_RD on TCP sockets - anomalous behaviour? Michael Kerrisk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox