TLS Buffer Allocation
TLS data flows through its own set of internal buffers that sit "behind" the socket's regular TX and RX buffers.
The WM2000 allocates the necessary TLS buffer space at boot, so no "manual" allocation in code is required. On the EM2000, EM2001, TPP2(G2), and TPP3(G2), you must call sock.tlsbuffrq followed by sys.buffalloc to allocate 39 buffer pages before attempting to establish a secure connection:
** Tibbo Basic **
sock.tlsbuffrq(39) 'A minimum of 39 buffer pages are required for TLS
Note that while 39 pages are sufficient for most TLS implementations, you might need to specify more if the certificate you're using has more fields than the minimum required.
Although sock.tlsbuffrq appears to allocate a single buffer, internally this space is actually divided into several buffers, such as "TLS TX," "TLS RX," and some other buffers needed for correct TLS operation: