Subject: Re: Integrating with libev

Re: Integrating with libev

From: Jérémy Lal <kapouer_at_melix.org>
Date: Mon, 23 Apr 2012 22:52:02 +0200

On 23/04/2012 22:31, Brian McFarland wrote:
> I'm using libev in my application and trying to figure out if c-ares is suitable for DNS.
>
> My general thinking is that I'll use a libev io watcher per socket created by c-ares. Then I'll just need to call ares_process_fd when the watcher wakes up. I'll also likely need a timer, which is probably as simple as reseting a libev timer to ares_timeout() every time an I/O callback wakes up.
>
> It looks like I can use the "ARES_OPT_SOCK_STATE_CB" to detect when I need to enable/disable my watchers (i.e. event listeners) for each socket.
>
> It also appears that ares_set_socket_callback can be used to detect when new sockets are created and in turn initialize my libev watchers.
>
> However, I'm not sure of the correct way to detect when sockets are closed so that I can safely destroy libev watchers. Is there a callback I'm missing that provides that information? If not, any thoughts on where to insert it?

Hello,
i have no idea what you're talking about, except for one thing :
Node.js is using c-ares and libev too.

Regards,
Jérémy.
Received on 2012-04-23