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: Simon Goldschmidt
Subject: Re: [lwip-users] Partial read on receive callback
Date: Fri, 13 May 2011 11:54:28 +0200

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
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de



reply via email to

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