5

I have rather simple UDP server written on c. Sometimes i need to know current length of all udp packets(bytes) queued in socket. As i understand, getsockopt doesn't get such information.

Linux and FreeBSD solutions are both welcome, thanks!

kost
  • 81
  • 2

2 Answers2

3

ioctl(FIONREAD, ...) should be roughly what you are looking for,

http://www.daemon-systems.org/man/ioctl.2.html

Steve-o
  • 12,678
  • 2
  • 41
  • 60
  • 1
    Actually this does not work on linux. See http://stackoverflow.com/questions/9278189/how-do-i-get-amount-of-queued-data-for-udp-socket – Anne Aug 28 '12 at 20:16
1

From outside of the server (command line), you can do

netstat -uln

which will show you the length of all listening udp sockets.

Anne
  • 480
  • 5
  • 14