lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] socket-based HTTP server


From: Marco Lazzaroni
Subject: Re: [lwip-users] socket-based HTTP server
Date: Fri, 3 Apr 2020 10:05:18 +0200

Il giorno gio 2 apr 2020 alle ore 20:27 address@hidden <address@hidden> ha scritto:
Am 01.04.2020 um 09:40 schrieb Marco Lazzaroni:
> Hi all,
> sorry for such a basic question. I've developed an application based on
> the raw API, then I had to integrate an RTOS and I had to switch to a
> socket based API.

You can continue using the callback API when using an OS, you just have
to make sure you only call into lwIP core functions from tcpip_thread or
surrounded by LOCK_TCPIP_CORE()/UNLOCK_TCPIP_CORE().
Ok thank you, good news for me! I thought it was not possible to use both APIs at the same time.  In particular, I have integrated the mbedtls library in order to do a HTTPS notification from my application, but the web server will be a standard HTTP server as before. Obviously I have to look better in what you suggested and try to implement it.
 
> To my understanding, the raw API based http server is run by code in
> lwip/src/apps/http/httpd.c.
> For the socket API, I started from
> lwip/contrib/apps/httpserver/httpserver-netconn.c and I wrote
> httpserver-socket.c making some obvious changes.

httpserver-netconn.c has *nothing* to do with the callback version
(httpd.c).

> Well, it works and it's quite stable, but now I need to implement CGI /
> SSI functionality in order to show the value of some variables.  I also
> need to import HTTP POST functionality that already worked with the raw API.
> I suppose that the code in httpd.c is not directly usable because it is
> for the raw API (correct?).
> I'm starting porting it to socket version by hand; i.e. I'm taking some
> pieces of http_parse_request() in order to parse the HTTP request, to
> get the URI, the HTTP/1.1 (or 0.9) string and so on.
> Anyway I'm asking myself if I have searched enough: is there something I
> can reuse for my purposes in the lwip tree? Or even outside it, being
> the socket API a standard, is there something reusable for an embedded
> web server?

There should be enough socket-based http servers in the net. That's why
we didn't invent yet another one.

I agree! In the meanwhile I had worked at the socket version, now I was roughly at a third of the job, but it's better to save it somewhere and switch back to the callback API.
Thank you again!
Best regards,
  Marco

reply via email to

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