[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] netconn: freeing netbufs after netconn_recv
From: |
Simon Goldschmidt |
Subject: |
Re: [lwip-users] netconn: freeing netbufs after netconn_recv |
Date: |
Thu, 1 Nov 2007 12:35:32 +0100 |
Am 31.10.2007 um 21:23 schrieb Ivan Delamer:
...
Now, I have two questions/concerns:
1) do I have to manually free/delete the netbuf? I read the source
code for netconn_recv and I see a buf = memp_malloc(MEMP_NETBUF)
but no "free" in the examples.
Yes, look at sockets.c, lwip_recv() implementation for an example.
2) for how long is the data in the netbuf valid? netconn_recv sends
a API_MSG_RECV so does this mean that the data may be overwritten?
or does it stay valid until I free the netbuf (and underlying pbufs)?
Data stays valid until you free the netbuf. API_MSG_RECV updates the
TCP window so that the remote side can send more data. If you don't
free the netbuf, you will eventually run out of pbufs/netbufs.
The way I see it, I should call netbuf_delete() after I'm done
processing the data, but I couldn't find any example of this.
As mentioned above, look at sockets.c, lwip_recv() implementation.
Thanks in advance again,
Ivan
PS: anybody have an HTTPD server sample? something more complex
than the example, I will use a thread pool for processing requests
and hopefully implement keep-alive.
The only netconn HTTPD example I know of is in the CVS contrib
module, apps directory.
Simon
Re: [lwip-users] netconn: freeing netbufs after netconn_recv, Ivan Delamer, 2007/11/01