In UNIX domain socket (AF_UNIX Type & DGRAM) , when a reader is slow , the no. of packets queued is 'max_dgram_qlen' . Is there any way to identify bytes occupied queued (or) no. of more bytes free in the queue either on the sender or receiver side. Or atleast , the writer is blocked when the queue is full. Is there any way identify the writer block event ? Thanks in advance.
-
1fyi... AF_INET+SOCK_DGRAM is a not a Unix domain socket, it's a TCP/IP socket using UDP.selbie– selbie2016-10-18 08:00:35 +00:00Commented Oct 18, 2016 at 8:00
-
Possible duplicate of: stackoverflow.com/questions/16427842/… . But I think you asking for how many bytes are queued on the sender side.selbie– selbie2016-10-18 08:01:19 +00:00Commented Oct 18, 2016 at 8:01
-
I have edited the question.And thanks for your suggestion.Chandira Mouli– Chandira Mouli2016-10-18 09:23:53 +00:00Commented Oct 18, 2016 at 9:23
Add a comment
|
2 Answers
- You can use the ioctl to find out.
To check a write buffer if it empty (assuming you have already put data there and want to check if they were consumed):
ioctl(fd, SIOCOUTQ, &pending);
Where fd is the socket’s file descriptor and pending the variable were the remaining size of data will be returned.
To check a read buffer if it empty (assuming someone has already put data there and you want to check if they there is any without consuming them):
ioctl(fd, SIOCINQ, &pending);
/*note the difference on the second parameter, where we change the flag from SIOCOUTQ to SIOCINQ*/
- Based on the error message returned by the send() function , we can identify the buffer full event.By checking the error==ENOBUFS you can identify the buffer full.
1 Comment
sourcejedi
2 is wrong. It refers to the device buffer, not the socket buffer. "ENOBUFS: The output queue for a network interface was full. This generally indicates that the interface has stopped sending, but may be caused by transient congestion. (Normally, this does not occur in Linux. Packets are just silently dropped when a device queue overflows.)"