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: Kieran Mansley
Subject: Re: [lwip-users] Partial read on receive callback
Date: Fri, 13 May 2011 10:24:06 +0100

On Fri, 2011-05-13 at 11:13 +0200, Enrico Murador - Research &
Development - CET wrote:
> It is ok for me to keep the data on the packet buffers, but I'm 
> concerned with the
> possibility that at the end of the buffer chain I will find a
> "partial" 
> message; in that
> case, If I understand well, I have two choices:
> 
> - Leave all the data in the buffers by not calling tcp_recved() and 
> waiting for another
>    chunk of data, hoping that at that time the buffers contains a 
> "complete" sequence
>    of messages (some of wich I could have already processed);
> - Copy the part of the uncomplete message in a separated buffer (and 
> advertise
>    the stack that I have processed all the data), chaining it with
>    the new data that will arrive the next time...
> 
> Am I supposing right?

Yes, either is fine.  Basically once you've finished with the buffer
that you're passed call tcp_recved().  You must finish with them in the
order you're given them (as tcp_recved() just takes the bytes you've
processed, and assumes that this refers to the next set of bytes).  You
can either copy the data out and call tcp_recved() straight away (your
second method above) or hold on to the buffers for now and call
tcp_recved() later when you've got a complete sequence (your first
method above).  Either is fine.  There are some differences between how
lwIP will behave in the two scenarios.  For example, if your sequence is
larger than a TCP window you'll need to use the second (copy) method, as
lwIP won't advertise more receive window space until you call
tcp_recved(), and so by delaying the call to tcp_recved() you might
result in zero window, and so the end of the sequence won't ever be
received.

Kieran




reply via email to

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