[Top][All Lists]

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

[lwip-users] Any experts on LWIP and the netconn API? (not looking for f

From: Peter
Subject: [lwip-users] Any experts on LWIP and the netconn API? (not looking for free; can pay)
Date: Tue, 02 Aug 2022 11:08:17 +0100

Hi All,

I am not sure this list is going anywhere but I will try anyway :)

I am implementing a simple web server. The code is all over the place.
It came with ST Cube IDE, and an identical version with same comments
is here

However, they assume incoming data (or the part of it of interest) is
contained in just the one buffer. The code is like this

>  err_t res = netconn_recv(conn, &inbuf);
>  if ((res == ERR_OK) && (inbuf != NULL))
>  {
>    if (netconn_err(conn) == ERR_OK) 
>    {
>      netbuf_data(inbuf, (void**)&buf, &buflen);
>      /* Is this an HTTP GET command? (only check the first 5 chars, since
>      there are other formats for GET, and we're keeping it very simple )*/
>      if ((buflen >=5) && (strncmp(buf, "GET /", 5) == 0))
>      {

netconn_recv appears to be a blocking function which tells you some
data has arrived.

netconn_err is a macro

netbuf_data reads in a buffer. There is no way to know how big this
buffer is, but you are told how much data is in there.

The problem I have is that I am extending this "server" (on which I
have spent at least a week full-time and which works solidly) with a
file upload feature, and that obviously involves getting a bit more
incoming data than just a few strings. There are almost no examples on
the web of using netconn for receiving a data stream of say 2MB.

I am wondering if the buffer pointed to by netbuf_data is actually one
of these, defined in lwipopts.h

>/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
>#define PBUF_POOL_SIZE           8
>/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
>// If small, set it so that say 3 of them hold a complete largest packet 
>#define PBUF_POOL_BUFSIZE        512

which would mean no more than 512 bytes. It kind of makes sense since
all the netconn code refers to pbufs.

There is also netbuf_next and I don't know how it fits into this

Basically I need some code which implements data receive, with a
timeout. The timeout I can do in various ways, with a FreeRTOS timer
being the most "modern" way. The buffer from which I will be writing
the eventual file is 512 bytes long. I can write less but can't write

On a related topic, am I right in saying that if
then the LWIP API is thread safe for raw, netconn and sockets, whereas
then the LWIP API is thread safe for netconn and sockets only?
There is a vast range of disagreement online about this topic.

Thank you in advance for any comments.


reply via email to

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