Skip to content

sending data out of mongoose polling context #3073

You must be logged in to vote

I see three possible paths:

  • polling
  • "async"
  • multithreading

Polling

As long as you don't violate the other end maximum wait time, nobody forces you to send a response immediately. When calling your event handler, Mongoose sets the is_resp flag https://mongoose.ws/documentation/#connection-flags , it will be reset when you call mg_http_reply(), but if you don't call it and just return, nothing will be sent and this connection will be kept open and waiting.
At a poll event, when you know your response is ready, you just call mg_http_reply().
Please read https://mongoose.ws/documentation/#best-practices
If you use mg_printf() or mg_send() instead, don't forget to set Content-Length and c->i…

Replies: 2 comments 1 reply

You must be logged in to vote
0 replies
Answer selected by scaprile

You must be logged in to vote
1 reply
@scaprile

scaprile Mar 9, 2025
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants