> > Is there a way to tell the kernel to discard all the messages in a
> > socket without having to recv() them?
> Closing the socket and eventually reopening an identically named one
> aftwards should accomlish this.
Albeit at the risk of missing messages between the time of close() and
the later bind() call.
I've always wondered, but never took the time to research/try, what
would happen if you set the SO_RCVBUF to some "Very Small Value" while
there was more than that Very Small Value's worth of data queued to
it, and then set it back up again. Of course that too runs the risk
of missing messsages, albeit perhaps for a smaller window.
However, since a UDP application is supposed to deal with the loss of
datagrams, if those windows were not opened too often, it might not be
so bad.
Finaly stream-of-consciousness typing - in some situations with UDP it
may be possible to use SO_REUSEADDR and/or SO_REUSEPORT to bind a
second socket to the same address as another. Ostensibly such a
socket created after the point of staleness detection would not
contain the stale datagrams. What remains as a question is to which
socket new datagrams would go while both were in existence. I'm sure
there is chapter and verse on that somewhere but it eludes my dimm
memory at the moment. Still, if the desired thing - newly arriving
datagrams go to the new socket (with going to the old being a
don'tcare) then one could create the new socket and close the old to
effect the "flush."
The whole thing does sort of beg the question though - what kept the
application from reading the datagrams out of the socket for so long
that they became uninteresting in the first place?
rick jones
--
portable adj, code that compiles under more than one compiler
these opinions are mine, all mine; HP might not want them anyway...

feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...