Subject: Re: Nameserver address which responded to query

Re: Nameserver address which responded to query

From: Manish Mehra <>
Date: Wed, 6 Jan 2021 13:40:51 -0800

Thanks Brad and Daniel.

If the application implements socket callbacks, following should be the
call flow where the library first invokes recvfrom callback and later
invokes the callback registered by application.


For single threaded application, nameserver address can potentially be
cached in recvfrom() and later used in ares_callback(). This is not very
elegant but a hack to get what we want to achieve. Of course, the cleanest
way would be to supply this information back to the application as a part
of ares_addrinfo structure. Will raise a PR for it sometime later

On Wed, Jan 6, 2021 at 7:05 AM Daniel Stenberg <> wrote:

> On Wed, 6 Jan 2021, Brad House wrote:
> > Unfortunately I don't have that answer, I'd have to dig into the code to
> see
> > under what circumstances connections are torn down with
> > ARES_FLAG_STAY_OPEN. Considering UDP connections aren't actually
> > connection-based, I'd suspect the fds aren't closed unless there is a
> hard
> > failure like no route in the host to the endpoint. That would mean it
> would
> > not have your intended side effect.
> In addition: even if it might work now, for some resolves, it seems very
> fragile and error-prone as isn't a guaranteed functionality and could just
> as
> well break in the next release etc.
> --
> /
Received on 2021-01-06