lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] How to correctly receive data


From: Mike Kleshov
Subject: Re: [lwip-users] How to correctly receive data
Date: Wed, 29 Jul 2009 11:31:31 +0400

2009/7/29 JM <address@hidden>:
>     while(data > 0)
>     {
>         data = data - (int)current_pbuf->len;
>         tcp_recved(pcb, current_pbuf->len);
>         next_pbuf = current_pbuf->next;
>         pbuf_free(current_pbuf);
>         current_pbuf = next_pbuf;
>     }

There is no need to walk the pbuf chain, pbuf_free() does that for
you. Calling tcp_recved() many times doesn't look right: that will
cause many redundant receive window update packets from lwip. Just
call it once with buf->tot_len.

err_t newdata(void *arg, struct tcp_pcb *pcb, struct pbuf *buf, err_t err)
{
    tcp_recved(pcb, buf->tot_len);
    pbuf_free(buf);
    return ERR_OK;
}




reply via email to

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