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 11:13:46 +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

Dear Kieran,
Thank you for the reply.
The callback won't be called again until there is new data, and the data
passed to the callback will only be the new data; it won't (I think)
pass you the data you've been given already as you were hoping.  I'm
afraid you have to create a list of the data you're interested in until
you've got enough to process.  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.

Kieran

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?

Thank you very much
Enrico


reply via email to

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