public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael Kerrisk" <m.kerrisk@gmx.net>
To: <linux-kernel@vger.kernel.org>
Subject: shutdown() and SHUT_RD on TCP sockets - anomalous behaviour?
Date: Thu, 24 Oct 2002 14:21:49 +0200	[thread overview]
Message-ID: <000301c27b59$f22964a0$0200a8c0@MichaelKerrisk> (raw)

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


                 reply	other threads:[~2002-10-24 12:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000301c27b59$f22964a0$0200a8c0@MichaelKerrisk' \
    --to=m.kerrisk@gmx.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox