[Libwebsockets] Async DNS resolver

Andy Green andy at warmcat.com
Sat Jul 5 06:02:32 CEST 2014

On 06/10/2014 11:52 PM, Carlos Sánchez wrote:
> Hi,
> I'm new here and using libwebsockets library.
> I've created a buildroot package for my old embedded linux system with
> the addition of small patches to achieve this. I want to use
> libwebsockets as client and server, but my first step will be as client
> and try to connect to pusher service and similar.
> With latency in mind and digging into the code, I've see calls to
> gethostbyname() and other DNS family functions witch are synchronous and

You're right.  But they're only used in 2 places... one is 
libwebsockets_get_peer_addresses() which is not called by the library 
itself, and the other is in the code to manage client connection to 
server... if you make sure the caller passed an IP address here it 
shouldn't take any time AFAIK.

> can block for long time the "loop" (I'm also using libev as event
> manager in my app) until name resolution. So my question is to know if
> will be async DNS option for future releases of the library in a similar
> fashion as CyaSSL and libev, i.e., as compile option. I'm using also a
> great library, libcurl with option to use async DNS using c-ares library
> that will be nice for libwebsockets. Probably I need to put all the
> libwebsockets client handling in a thread to handle requests, but I want
> to try first do in the "loop" and even in the thread, async DNS will be
> nice to make more responsive multiple connections.

No I don't think we have that problem, because by default we don't care 
about name resolution or reverse lookup.

> I suppose that there are many other locking functions (like
> libwebsockets_serve_http_file()), but at the moment, this is the only
> one that I see with long time response..

No if you look closer at it, you'll see it is absolutely not blocking.


> Thanks in advance.. and nice job!
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets

More information about the Libwebsockets mailing list