3

I need to get the amount of datagrams queued/pending in a unix datagram socket and yet to be received. I see that max_dgram_qlen gives what is the maximum of datagrams that can be queued in the receive buffer after which it will be blocked. But, is there a way to how much datagrams is already queued for unix datagram socket via some socket options or via reading some linux files. Please let me know. Thanks.

Andrew Henle
  • 32,625
  • 3
  • 24
  • 56
Kumar
  • 31
  • 2
  • Note that any value you obtain may already be wrong/out-of-date by the time you actually get a chance to do anything with the value. You might be better off coming up with a design that doesn't try to depend on that information. – Jeremy Friesner Oct 24 '16 at 21:02

1 Answers1

1

read /proc/net/udp

From the man page:

/proc/net/udp

Holds a dump of the UDP socket table. Much of the information is not of use apart from debugging. The "sl" value is the kernel hash slot for the socket, the "local_address" is the local address and port number pair. The "rem_address" is the remote address and port number pair (if connected). "St" is the internal status of the socket. The "tx_queue" and "rx_queue" are the outgoing and incoming data queue in terms of kernel memory usage. The "tr", "tm->when", and "rexmits" fields are not used by UDP. The "uid" field holds the effective UID of the creator of the socket. The format is:

sl  local_address rem_address   st tx_queue rx_queue tr rexmits  tm->when uid
1: 01642C89:0201 0C642C89:03FF 01 00000000:00000001 01:000071BA 00000000 0
1: 00000000:0801 00000000:0000 0A 00000000:00000000 00:00000000 6F000100 0
1: 00000000:0201 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0
Malt
  • 28,965
  • 9
  • 65
  • 105