Report
3 months ago.

Function recv () does not receive more than 536 bytes

Hi,

Function recv (void *data, nsapi_size_t size) receive data over a TCP socket and returns the number of bytes received in the buffer, but not more than 536 bytes.

See https://os.mbed.com/docs/v5.9/reference/tcpsocket.html

int n = recv(buffer, sizeof(buffer)); How can I receive more than 536 bytes, for example 1460?

Not working

mbed_app.json

{   "target_overrides": {
        "*": {
            "target.features_add": ["LWIP"],
            "lwip.pbuf-pool-bufsize": 1460
        }
    }
}

#define TCP_MSS 1460  // not working

Thanks...

Comment on this question

1 Answer

3 months ago.

This depends on the radio driver, networking stack, etc. Which board are you working on? Just read multiple times until recv returns 0 bytes (or will block error code).

I'm using FRDM-K64F I wanted to change the maximum size of one segment (TCP_MSS - TCP maximum segment size, default is 536). My requests are no more than 700 bytes in size.

posted by Nikolai Zimfer 10 Sep 2018

But the stack will never guarantee that everything will fit in one packet. Maybe your link is slow and a slower data rate is negotiated. Always keep calling recv() until it does not yield any more data.

posted by Jan Jongboom 11 Sep 2018

To post an answer, please log in.