![]() |
libwebsockets
Lightweight C library for HTML5 websockets
|
Functions | |
LWS_VISIBLE LWS_EXTERN void | lws_set_timeout (struct lws *wsi, enum pending_timeout reason, int secs) |
LWS_VISIBLE LWS_EXTERN void | lws_set_timer_usecs (struct lws *wsi, lws_usec_t usecs) |
LWS_VISIBLE LWS_EXTERN int | lws_timed_callback_vh_protocol (struct lws_vhost *vh, const struct lws_protocols *prot, int reason, int secs) |
APIs related to setting connection timeouts
LWS_VISIBLE LWS_EXTERN void lws_set_timeout | ( | struct lws * | wsi, |
enum pending_timeout | reason, | ||
int | secs | ||
) |
#include <lib/libwebsockets.h>
lws_set_timeout() - marks the wsi as subject to a timeout
You will not need this unless you are doing something special
wsi | Websocket connection instance |
reason | timeout reason |
secs | how many seconds. You may set to LWS_TO_KILL_ASYNC to force the connection to timeout at the next opportunity, or LWS_TO_KILL_SYNC to close it synchronously if you know the wsi is not the one currently being serviced. |
LWS_VISIBLE LWS_EXTERN void lws_set_timer_usecs | ( | struct lws * | wsi, |
lws_usec_t | usecs | ||
) |
#include <lib/libwebsockets.h>
lws_set_timer_usecs() - schedules a callback on the wsi in the future
wsi | Websocket connection instance |
usecs | LWS_SET_TIMER_USEC_CANCEL removes any existing scheduled callback, otherwise number of microseconds in the future the callback will occur at. |
NOTE: event loop support for this:
default poll() loop: yes libuv event loop: yes libev: not implemented (patch welcome) libevent: not implemented (patch welcome)
After the deadline expires, the wsi will get a callback of type LWS_CALLBACK_TIMER and the timer is exhausted. The deadline may be continuously deferred by further calls to lws_set_timer_usecs() with a later deadline, or cancelled by lws_set_timer_usecs(wsi, -1).
If the timer should repeat, lws_set_timer_usecs() must be called again from LWS_CALLBACK_TIMER.
Accuracy depends on the platform and the load on the event loop or system... all that's guaranteed is the callback will come after the requested wait period.