311
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
buffer. Allocation is requested through the
method.
Actual memory allocation is done through the
method which
applies to all buffers previously specified. Here is an example:
dim
b1, b2, b3, b4, b5
as
byte
...
'setup for other objects, sockets, etc.
b1= sock.txbuffrq(
5
)
'you need this buffer to send regular data
b2= sock.rxbuffrq(
5
)
'you need this buffer to receive regular data
b3= sock.cmdbuffrq(
1
)
'buffer for incoming inband commands
b4= sock.rplbuffrq(
1
)
'buffer for outgoing inband replies
b5= sock.tx2buffrq(
5
)
'same buffer size as for the TX buffer
....
sys.buffalloc
' Performs actual memory allocation, as per previous
requests
Actual memory allocation takes up to 100ms, so it is usually done just once, on
boot, for all required buffers.
You may not always get the full amount of memory you have requested. Memory is
not an infinite resource, and if you have already requested (and received)
allocations for 95% of the memory for your platform, your next request will get up
to 5% of memory, even if you requested for 10%.
There is a small overhead for each buffer. Meaning, not 100% of the memory
allocated to a buffer is actually available for use. 16 bytes of each buffer are
reserved for variables needed to administer this buffer, such as various pointers
etc.
Thus, if we requested (and received) a buffer with 2 pages (256 * 2 = 512), we
actually have 496 bytes in which to store data (512 - 16).
If you are changing the size of any buffer for a socket using sys.
buffalloc, and this socket is not closed (
is not
PL_SSTS_CLOSED), the socket will be automatically closed. Whatever
connection you had in progress will be discarded. The socket will not be
closed if its buffer sizes remain unchanged.
Processing Inband Commands
What goes into the CMD buffer
All incoming inband commands are stored into the CMD buffer. At any given time
the buffer may contain more than one command. Each inband message in the
buffer already has its escape character and the character after the escape
character removed. The end character, however, is not removed and can be used
by your program to separate inband messages from each other.
Here is an example. Supposing, you have the following setup:
361
217
358