Handling Buffer Overruns
Handling RX buffer overruns
The on_sock_overrun event is generated when an RX buffer overrun has occurred. It means the data has been arriving to the RX buffer faster than you were handling it and that some data got lost.
This event is generated just once, no matter how much data is lost. A new event will be generated only after exiting the handler for the previous one.
Normally, data overruns will not occur when the TCP transport protocol is used. This is because the TCP is intelligent enough to regulate the flow of data between the sender and the receiver and, hence, avoid overruns. The UDP protocol does not have a "flow control" mechanism and RX buffer overruns can and will happen.
Typically, the user of your system wants to know when an overrun has occurred. For example, you could blink a red LED when this happens.
** Tibbo Basic **
sub on_ser_overrun pat.play("R-R-R-R") end sub
Are TX buffer overruns possible?
TX buffer overruns are not possible. The socket won't let you overload its TX buffer. If you try to add more data to the TX buffer than the free space in the buffer allows to store then the data you are adding will be truncated.
See Sending Data for explanation on how to TX data correctly.