[Twisted-Python] Twisted names client.getHostbyName dual-stack operation

Maciej Wasilak wasilak at gmail.com
Mon Jan 6 01:26:18 MST 2014


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, so
it often causes communication to fail. I've found a solution to override
this behavior with monkey patching [1].

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?
2. Does someone know a less hacky solution to get IPv4 addresses with
getHostbyName()?

Best Regards
Maciej Wasilak

[1]
http://stackoverflow.com/questions/13820175/can-twisted-names-client-be-forced-to-return-ipv4-addresses-without-modifying
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20140106/f751096c/attachment.html>


More information about the Twisted-Python mailing list