[Top][All Lists]

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

[lwip-users] netconn: freeing netbufs after netconn_recv

From: Ivan Delamer
Subject: [lwip-users] netconn: freeing netbufs after netconn_recv
Date: Wed, 31 Oct 2007 13:23:44 -0700 (PDT)

Hi again,

I'm trying to implement a small HTTP server with Keep-alive, so incoming TCP 
connections stay open for multiple interactions.

I'm now using netconn API.

Thanks to the previous answers, I am now able to properly process received 
segments. Code is approx.:

  do {
      char *data;
      int len;
      /* obtain a pointer to the data in the fragment */
      netbuf_data(buf, &data, &len);
      /* do something with the data */
      do_something(data, len);
  } while(netbuf_next(buf) >= 0);

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 

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)?

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.

Thanks in advance again,

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.

Yahoo! Noticias
Todo lo que tenés que saber sobre Elecciones Presidenciales 2007 encontralo en 
Yahoo! Noticias.

reply via email to

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