mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-29 06:08:59 +08:00
7bed7ff482
Comments in headers are changed a bit: removed adoc-specific stuff, markdown is used instead PUBLISHED_FROM=9242cce85cc52a47a197d377e7e23804721a6bb5
799 B
799 B
title | decl_name | symbol_kind | signature |
---|---|---|---|
mg_set_timer() | mg_set_timer | func | double mg_set_timer(struct mg_connection *c, double timestamp); |
Schedule MG_EV_TIMER event to be delivered at timestamp
time.
timestamp
is a UNIX time (a number of seconds since Epoch). It is
double
instead of time_t
to allow for sub-second precision.
Return the old timer value.
Example: set connect timeout to 1.5 seconds:
c = mg_connect(&mgr, "cesanta.com", ev_handler);
mg_set_timer(c, mg_time() + 1.5);
...
void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
switch (ev) {
case MG_EV_CONNECT:
mg_set_timer(c, 0); // Clear connect timer
break;
case MG_EV_TIMER:
log("Connect timeout");
c->flags |= MG_F_CLOSE_IMMEDIATELY;
break;