lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Partial read on receive callback


From: Enrico Murador - Research & Development - CET
Subject: Re: [lwip-users] Partial read on receive callback
Date: Fri, 13 May 2011 15:22:31 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10

Ok, now it's very clear and I have a couple of options to try...

Thank you all for your support!
Enrico

On 13/05/2011 11.54, Simon Goldschmidt wrote:
Kieran Mansley <address@hidden> wrote:
You don't need to copy it, as this is the
point of tcp_recved() - it allows you to keep hold of the data until
you've finished with them, even if that's not straight away during the
callback.  Once you've processed and finished with the data, call
tcp_recved() and the stack will be allowed to reuse those buffers.
Actually, tcp_recved() only updates the TCP window, it does not free data: Once a pbuf has been passed to a recv-callback, it is up to the application to free it (unless returning != ERR_OK, but that's another issue).

So you are free to keep the pbufs pass to your callback on your own list (you can even chain them, as long as tot_len fits into an u16_t), call tcp_recved() for the window to be updated and return ERR_OK to tell the stack that you took over the pbuf.

Delaying tcp_recved() might really not be the best idea, as it might prevent the remote side from sending more data. However, that depends on your application and the window size.

Then, it's up to you if you want to copy the data into a buffer or parse the linked list of pbufs every time you received a new pbuf. This mainly depends on RAM and speed: copying takes some time and RAM, but always scanning a linked list of pbufs may be slow, too.

Simon


reply via email to

[Prev in Thread] Current Thread [Next in Thread]