Maximum TCPCLIENT buffer size?

In our project, which employs the Electron (E0), I would like to be able to send from a web site a large burst of data (maybe 2000 characters) including initialization parameters, but only upon initialization of a new installation using JSON, and HTTP. Presently the project is working with “TCPClient client; char buffer[1576];” set to 1576. I was not able to find the maximum character buffer allowed. Can you tell me what is the maximum size data batch I can send in one burst? Will 2000 characters be too much? Does the E0 have a limit on how much data it can accept or is this just limited by the E0 memory available? Also, is there a way I can determine how much memory space is still available in the E0 for such a character buffer? I am not the programmer, but I’m thinking of how I could add a feature to our project, and the answer to this question would help me plan.

On Gen 2 cellular devices (Electron and E Series), there is no advantage of using a write greater than 512 bytes. It will work, but the end result is that it’s sent in 512 byte chunks internally.

A better code structure is to create a buffer with your entire transmission, and send it 512 byte chunks. The other thing you need to do is make sure you check the result from write(). It’s the number of bytes that were written. It’s possible that this will be less than the amount you requested, and you should increment your buffer position by that amount, not the amount you wanted to write.

The size of your larger buffer is limited by available RAM, which you can find using System.freeMemory() if you allocate it on the heap.

If you allocate it on the stack, the entire stack is 6K bytes but that also includes any local variables allocated on the stack in the function and up the call stack. I wouldn’t use a stack allocated buffer larger than 1K, but you might be able to get away with 2K.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.