[Libwebsockets] LWS_CALLBACK_CLIENT_CONNECTION_ERROR handling with external polling?

Matt Sarnoff matt.sarnoff at gmail.com
Mon Jan 18 18:31:01 CET 2016


Thanks, Andy. libuv (what I'm using) and libev seem to have diverged a few
years ago, and unfortunately I'm not familiar enough with the latter to
code something worth sharing. :p

It would be cool if the library used the callback to register/unregister
timeout handlers, similar to how LWS_CALLBACK_{ADD/DEL/CHANGE_MODE}_POLL_FD
are used. The libcurl multi API provides a similar feature--the
CURLMOPT_TIMERFUNCTION option allows an API consumer to register a custom
timeout handler.

Thanks,
-matt



On Sun, Jan 17, 2016 at 8:02 PM, Andy Green <andy at warmcat.com> wrote:

>
>
> On January 17, 2016 8:53:17 AM GMT+08:00, Matt Sarnoff <
> matt.sarnoff at gmail.com> wrote:
> >I'm currently using libwebsockets 1.6.0 in a client application with an
> >external polling mechanism provided by a libuv event loop. I'm not
> >calling
> >lws_service() at all.
> >
> >I'm finding that I never receive LWS_CALLBACK_CLIENT_CONNECTION_ERROR
> >for
> >connection timeouts, e.g. if I specify a nonexistent host name. If I
> >call
> >lws_service() in a loop, I receive the callback after about 5 seconds,
> >as
> >expected.
> >
> >My current solution involves calling lws_client_connect_via_info(),
> >then
> >calling lws_service() periodically from a uv_timer_t
> >until LWS_CALLBACK_CLIENT_ESTABLISHED is received or the connection
> >fails.
> >Is there a better way to handle this scenario?
>
> The guy who added the basic libev support left a comment that somebody
> should implement timeouts using libev api, I guess that is what he meant.
>
> In the service code once a second he will check everyone to see if they
> crossed a timeout limit.  But the libev code as you say deals with events
> only in the libev realm.
>
> Can you share your existing code for this and I'll try to integrate it on
> the library side, just for timeout processing.
>
> -Andy
>
> >
> >Thanks,
> >-matt
> >
> >
> >------------------------------------------------------------------------
> >
> >_______________________________________________
> >Libwebsockets mailing list
> >Libwebsockets at ml.libwebsockets.org
> >http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20160118/bac31aef/attachment-0001.html>


More information about the Libwebsockets mailing list