[Twisted-Python] Twisted names client.getHostbyName dual-stack operation
Phil Mayers
p.mayers at imperial.ac.uk
Mon Jan 6 04:47:40 MST 2014
On 06/01/14 08:26, Maciej Wasilak wrote:
> Hello,
>
> I've tried to use Twisted names.client.getHostByName() method to resolve
> some addresses for my UDP based app. By default getHostByName() always
> returns IPv6 address. I don't always have end-to-end IPv6 connectivity,
I'm not sure if t.n.client implements the same stuff that getaddrinfo
does, namely RFC 6724 address selection rules and behaviour, and in
particular if it has an equivalent of the AI_ADDRCONFIG flag.
> After Twisted 13.2 announcement I've checked the new HostnameEndpoint
> implementation to find possible solution (it seems to be dedicated to
> solve similar problems, but for TCP-based protocols). However it seems
> to use deferToThread(), and built-in Python getaddrinfo().
>
> My questions:
> 1. Is using deferToThread() a preferred solution?
IMO *all* applications should *always* use getaddrinfo() for resolution
of user-supplied names. It really really annoys me when people decide to
re-invent it - this is hard to get right, and apps like Chrome having
their own implementation precludes things like DHCP-based 6724 tables in
the future.
So yes, use "deferToThread" and "getaddrinfo". Note that you should not,
in general, specify the address family; let the AI_ADDRCONFIG flag sort
that out for you.
More information about the Twisted-Python
mailing list