Results 1 to 5 of 5
I have a blocking sento call issued by my application. The packets are UDP.
1. What will happen when the n/w driver's queue gets filled?
2. If linux silently starts ...
- 04-24-2009 #1Linux Newbie
- Join Date
- Mar 2008
- Location
- Hyderabad
- Posts
- 109
[SOLVED] sendo hang
I have a blocking sento call issued by my application. The packets are UDP.
1. What will happen when the n/w driver's queue gets filled?
2. If linux silently starts discarding packets will my sendto hang forever?
3. What does sendto ensures I mean at what point does it returns. Does its reponsibility includes making sure that the packet is inserted in the queue of driver and keep on retrying till then or it just sends the packet to driver and returns not caring whether the driver drops the packets in case its queue is filled?
Thanks in advance
- 04-24-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,961
UDP is the wire-level protocol. There is no guarantee of delivery to the recipient, but that is irrelevant to the actual API sendto() call you make. If you send a blocking message and the n/w driver's queue is full, you will wait unless the call is interrupted, in which case you should get an EINTR error. Linux itself won't silently drop packets, but the network itself might. Again, what I said about UDP above. Once the network driver has the packet, then sendto() should return. Again, with UDP connections, all you are guaranteed is that the system put the packet on the net.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 04-25-2009 #3Linux Newbie
- Join Date
- Mar 2008
- Location
- Hyderabad
- Posts
- 109
Thanks rubberman
"Once the network driver has the packet, then sendto() should return"
that solved my problem. So sendto is responsible upto insertion of packet inside the driver queue.
I was doubting if its responsible till linux stack only and further insertion into driver queue was responsibility of the stack itself. In case the driver queue is full the stack will make sure to make a retry for the insertion.
Thanks for clearing the doubt.
sendto is going to hang in my case.
- 04-25-2009 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,961
You could set the MSG_DONTWAIT flag on the call, and check for errno == EAGAIN if it returns less bytes than you sent or -1 (locally detected error). From the send/sendto man page:
When the message does not fit into the send buffer of the socket, send() nor-
mally blocks, unless the socket has been placed in non-blocking I/O mode. In
non-blocking mode it would return EAGAIN in this case. The select(2) call
may be used to determine when it is possible to send more data.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 04-26-2009 #5Linux Newbie
- Join Date
- Mar 2008
- Location
- Hyderabad
- Posts
- 109
Thanks Rubberman,
I have opted for the non bloking version.
Thanks again



