Socket flush

Jonathan I. Kamens jik at athena.mit.edu
Mon Mar 18 15:36:10 AEST 1991


In article <511 at shrike.AUSTIN.LOCKHEED.COM>, dcj at AUSTIN.LOCKHEED.COM (David Jacobson rimux) writes:
|> I was wondering how to clear all buffered data in for a socket
|> (say, if a certain interrupt were received) without closing
|> the socket.

  Could you explain a bit more clearly what you're trying to do?

  Are you talking about a socket that you're reading from, or a socket that
you're writing to?  Are you saying that you're using stdio to access the
socket, and want to flush everything in the stdio buffers, or that you want to
tell the kernel to discard any text waiting to be read in the socket?

  If you want to do the latter, my suspicion is that you're just going to have
to read the data from the socket and throw it away.  The only call I know of
(and I may just be forgetting something here, but I don't think so {of course,
if I am forgetting something, I wouldn't know about it so I still wouldn't
think so :-)}) that does anything about flushing socket data is shutdown(),
and you don't want to do that because you won't be able to do any more reading
after you shutdown a socket.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.programmer mailing list