0

what will be done if the buffer socket full in an UDP protocol? does it replace the old data with the new one? ot it just drop the new data?

In case that it's not related with UDP protocols, and it's specified in the code, how to do this in python and C?

1 Answers1

0

For output buffer (i. e. the one holding packets to be sent), sendto() or similar call will block until the space is available in the buffer.

For input buffer (i. e. the one holding received packets), it depends on OS networking stack implementation, strictly speaking. In Linux, new packets are dropped silently. In any case, it will not be an error if some packets are lost this way, as UDP does not guarantee their delivery.

BTW, there is no such thing as a "UDP connection".

PlushBeaver
  • 346
  • 1
  • 9
  • Is there a way to make OS replace the old data with the new one? –  Jun 08 '15 at 17:32
  • Not for Windows and (unmodified) Linux. You can adjust receive buffer size, though: see [this question](http://stackoverflow.com/questions/18985816/change-default-socket-buffer-size-under-windows) for Windows and `udp(7)` manual page for Linux. I've no practical knowledge of *BSD, Solaris, etc., but AFAIK all popular OS act the same here. – PlushBeaver Jun 08 '15 at 17:43