307
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
data into the TX buffer and execute
, the socket won't send this data
out unless entire contents of the TX buffer can be sent out in a single TCP packet.
Here is an example of how you can use that:
sock.splittcppackets=YES
...
...
sock.setdata("ABCDEFGH1234567890")
sock.send
while
sock.txlen>0
doevents
wend
Notice that this method has its disadvantage -- your data throughput is diminished
because your program is seeking an acknowledgement for each TCP packet being
sent. On the other hand, this is a bulletproof way of making sure that the outgoing
TCP packet contains exactly the data you intended.
Be careful not to try to send more data than the RX buffer size on the other end.
Since in this mode the socket won't send that data unless it can send all of it, your
TCP connection will get stuck!
Also, attempting to send the packet with size exceeding the "maximum segment
size" (MSS) as specified by the other end will lead to data fragmentation! The
socket will never send any TCP packet with the amount of data exceeding MSS.
Handling Buffer Overruns
Handling RX buffer overruns
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.
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
for explanation on how to TX data correctly.
353
343
304