This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

TCP message size

I would like to send TCP message with 50KB message size.
I saw that maximum size was limited by CONFIG_HEAP_MEM_POOL_SIZE which was 16kB.

Is there any way to send that message ?

  • Assuming you can build/hold your entire message in RAM ready to go, TCP doesn't explicitly distinguish packets at the application layer, so you can send it as a bunch of smaller chunks back-to-back.  Something like this:

    int socket_write(int sock, const u8_t *data, u32_t datalen)
    {
       u32_t offset = 0U;
       int ret;
    
       while (offset < datalen)
       {
          ret = send(sock, data + offset,
                     MIN(2048, (datalen - offset)), 0);
          if (ret < 0)
          {
             return -errno;
          }
    
          offset += ret;
       }
    
       return 0;
    }

Related