316
Platforms
©2000-2008 Tibbo Technology Inc.
three or four pages, there is a significant performance improvement. Additional
buffer pages do not lead to any dramatic improvements in performance.
VAR buffer. Dynamic HTML pages include snippets of BASIC code and this code
may need to know variable passed to the HTTP server using GET or POST
methods. The VAR buffer stores those variables. Do the allocation with the
method. Buffer size of one page is usually OK. If the application is
to handle large amounts of variable data, such as in the case of file uploads, you
can improve the performance by allocating more pages.
Actual memory allocation is done through the
method which
applies to all buffers previously specified. Here is an example:
Dim
f
As
Byte
...
'setup for other objects, sockets, etc.
'setup buffers of sockets 8-15 (will be used for HTTP)
For
f=8
To
15
sock.num=f
sock.txbuffrq(1)
'you need this buffer for HTTP requests and replies
sock.varbuffrq(1)
'you need this buffer to get HTTP variables
sock.redir(PL_REDIR sock.num)
'this will allow us to avoid
wasting memory on the RX buffer
Next
f
....
sys.buffalloc
' Performs actual memory allocation, as per previous
requests.
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.
365
217
358