Page 1 of 1

Let esp_http_server running another handler while infinite loop

Posted: Tue Jan 02, 2024 11:08 am
by ipgdbali
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

Re: Let esp_http_server running another handler while infinite loop

Posted: Tue Jan 02, 2024 10:31 pm
by MicroController
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.