Skip to content

is there any option that can specifiy a timeout when using msg_connection? #1592

Discussion options

You must be logged in to vote

Connect timeout should be done manually.
The idea is: when a connection is created (MG_EV_OPEN event), store current timestamp (mg_millis()) into a c->label buffer. Then, on each MG_EV_POLL, check the current timestamp and c->is_connecting / c->is_resolving flags. Close if takes too long.

The http-client example has that implemented - https://github.com/cesanta/mongoose/blob/master/examples/http-client/main.c

We probably should move that into a separate example and tutorial.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by cpq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants