Let esp_http_server running another handler while infinite loop

ipgdbali
Posts: 1
Joined: Tue Jan 02, 2024 11:03 am

Let esp_http_server running another handler while infinite loop

Postby ipgdbali » Tue Jan 02, 2024 11:08 am

I'm streamming MJPEG with esp_http_server.h.
Within one of its handler I make an infinite loop ( while(true) ).
I want to process another handler while in infinitive loop.

How to do that ?

Thanks

MicroController
Posts: 1708
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Let esp_http_server running another handler while infinite loop

Postby MicroController » Tue Jan 02, 2024 10:31 pm

Don't loop inside the HTTP request handler.
Instead, use httpd_req_to_sockfd() to get the connection's socket when handling the request; pass this socket to another task and return from the request handler. The other task can then loop using httpd_socket_send() to send data while the HTTP server is free to handle other requests.

Who is online

Users browsing this forum: No registered users and 101 guests