lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] How to receive only some data


From: Goldschmidt Simon
Subject: RE: [lwip-users] How to receive only some data
Date: Thu, 12 Jul 2007 08:28:05 +0200

> However, there are times where I am not able to process all 
> of the information.  What is the proper way to do it?  I 
> assume I should
> tcp_recved() the length I processed.  But, should I do a 
> pbuf_free() even if I didn't process all of it?  Basically, I 

No! The data is not copied anywhere in the stack, so the pbuf you got is
the only place where the data is (no second copy) and once given to your
tcp_recv callback, you are the only one holding a reference (i.e. the
stack doesn't reference this pbuf any more). So freeing the pbuf would
delete the data!

Calling tcp_recved is only there to update the window size (a tcp window
update packet will be sent).

> am funnelling all received data into a non-blocking named 
> pipe (fifo), and I need to push back on the stack if the fifo 
> is full.  But when room becomes available in the fifo, I can 
> start processing the tcp data again.
> 
> Let's say that I am unable to process any data for awhile and 
> my TCP receive window is full.  Will the stack still periodically call
> tcp_recv() to poll the application?  Or do I need to use 
> tcp_poll and somehow find the received data myself?

No, the stack only calls tcp_recv with NEW data.
The only solution is for you to hold the pbuf pointer and process it
later.
That can be done in tcp_poll or when receiving new data (of course as
you
said, if the recv window is full, you won't receive any more data so you
have
to do that in tcp_poll).

Hope that helps.


Simon




reply via email to

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