"Barry Margolin" <ba************@level3.com> wrote in message
news:KO***********@news.level3.com...
In article <Um*******************@news-binary.blueyonder.co.uk>,
Terry Sanders <no****@vertone.co.uk> wrote:For various reasons I need to how many packets are queued in the
SO_RCVBUFof a udp socket. I know there are various mechanisms for detecting if
thereis one
or more packets queued, but I cant find anything to tell me exactly how
manyare queued.
Does anybody have any idea how to get this information. I currently need
this for linux.
You could try using the FIONREAD ioctl, but I don't know if it's
guaranteed to work or portable. However, if it works it will tell you how many bytes
are in the queue, not how many packets.
Why do you need to know this, anyway? If another packet arrives after the
call returns, the information will be wrong.
Doesn't FIONREAD return the number of bytes in the next udp packet
(+ addr len) as opposed to the number of bytes in the RCVBUF?
What I'm doing is developing an application to test the capabilities
of another. At any one time it has to decide whether to send the next
packet, read a packet, act on a packet already read (which may involve
sending another packet), process timeouts on previous packets sent or
any one of a number of other things. By knowing how many packets are in
the read queue the application can make decisions on whether in can
safely ignore the contents of the read queue, until the next pass, in
favour of processing other parts which may be running behind.
Terry Sanders