lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Again confused about tcp_recved() and pbuf_free()


From: Simon Goldschmidt
Subject: Re: [lwip-users] Again confused about tcp_recved() and pbuf_free()
Date: Tue, 26 Feb 2019 09:43:20 +0100

Giuseppe Modugno wrote:
[..]
> >> What are the situations when it should be better to not call 
> >> tcp_recved() in recv() callback()? Here the application has the 
> >> received data, can process and free the pbufs or can avoid freeing 
> >> the pbufs to wait for additional data. In both cases I think the 
> >> application should call tcp_recved().
> >
> > If you need to process the received data further at slower speed, it's 
> > better to not call tcp_recved() right away. For example if you're 
> > programming into slow flash, calling tcp_recved after the bytes are 
> > programmed ensures the client does not send faster than you can program.
> 
> In this case you don't free the pbuf, because data is being written to 
> the Flash. So it seems to me that when you free the pbuf (you have 
> processed the incoming data), you can call tcp_recved(). If you don't 
> free the pbuf, you haven't processed the data yet, so you don't call 
> tcp_recved().
> 
> I don't understand when the two things can be different.

They might be the same for you. But if you have a different buffering
scheme (e.g. a ring buffer for flash writes or whatever), it could be
different. With a library like lwIP, you just don't know how it will
be used in the actual targets.

Regards,
Simon



reply via email to

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