mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rob Landley <landley@trommello.org>
To: linux-kernel@vger.kernel.org
Subject: Obscure networking question (shutdown on socket WITHOUT discarding data...)
Date: Thu, 6 Jun 2002 16:19:08 -0400	[thread overview]
Message-ID: <20020607024846.81BF37C8@merlin.webofficenow.com> (raw)

Is there a way to call shutdown(blah, SHUT_WR) on a network SOCK_STREAM 
connection's fd without discarding pending output?  Or some way to block 
until pending output has been acknowledged by the far end?  (There's a TCP/IP 
acknowledgement packet being sent, I'm fairly certain of this...)

I want the connection at the far end to get EOF from read, but still be able 
to send me data back from the other half of the connection.

I've looked at the BSD networking documentation, the source code to "netcat", 
all the man pages I could find, asked google, etc.  The 2.4.18 net/ipv4/tcp.c 
source has some interesting comments (line 396) about poll not having a 
notion of HUP in just one direction, but I've gathered that select and poll 
behave differently on files, pipes, network sockets, block devices, etc...  
In any case, this doesn't help me find an exported user-space API that might 
help me implement this behavior.  (By the way, is "PULLHUP" on lines 414 and 
417 a typo for "POLLHUP", or not?)

There doesn't seem to be any variant of a blocking flush() call on a socket 
(that I can find), or a way to tell shutdown() to wait for pending output the 
way a normal close() does.  (Maybe I can do something fancy with poll or 
select?)

If there IS no way to do this, why does shutdown(2) bother taking a second 
argument?

(Maybe I can disable nagle and then do a write of length zero, to make the 
other end unblock with a read of length zero and THINK the stream's done?  
Probably won't work, but it's worth a try...)

Rob

(P.S.  yes I can rewrite the protocol being sent over the wire to signal EOF 
in-band (yet again) but this keeps coming up over and over.  Processes that 
work when stdin and stdout are seperate file handles don't work when the data 
goes back and forth through a network socket...)

             reply	other threads:[~2002-06-07  2:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-06 20:19 Rob Landley [this message]
2002-06-07 15:25 ` Alan Cox

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=20020607024846.81BF37C8@merlin.webofficenow.com \
    --to=landley@trommello.org \
    --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

all inboxes | Powered by JetHome®