lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] flow of lwip as a stream client


From: Stephane Lesage
Subject: Re: [lwip-users] flow of lwip as a stream client
Date: Fri, 2 Mar 2012 16:35:20 +0100

> if(GetBufferFreeSize) //  are there free space in the buffer?
> {
>    pbuf_copy_partial (xxx, buf, GetBufferFreeSize, xxx );
>    tcp_recved(xxx, GetBufferFreeSize);
>    copy_to_buffer(buf, GetBufferFreeSize); }
> 
> It is by far not complete but I guess you understand what I mean.
> Back to my question: Lets say my buffer is full. the tcp callback is
> called by lwip. I cannot process the bpuf so I will not call
> tcp_recved(). What should I do will the pbuf? Or do you think the tcp
> receive callback is not called at all?

Hi trex7,
By doing this, you acknowledge the data immediately so the server will
always send you more data than you can buffer (up to your TCP window
size).
So now what can you do with this ?
- discard the pbuf and return an error -> leads to retransmissions
- keep a list of pbuf without calling tcp_recved() -> shrink the window,
but you will have take them when you have space in your buffer


So, why don't you just use your received pbuf(s) directly in your audio
function ?
This way:
- the size of your "buffer" (made of pbufs) is the size of your TCP
window
- the server cannot send more
- no copy, less memory used (only the TCP window vs buffer + TCP window)


-- 
Stephane Lesage



reply via email to

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