[Twisted-Python] Reliable way to check if Twisted has IPv6 support?
Phil Mayers
p.mayers at imperial.ac.uk
Fri Dec 13 03:41:44 MST 2013
On 13/12/13 03:22, Amit Saha wrote:
> Is there a more reliable way (which works with the Twisted-8.0+) to check this?
Check the Twisted version.
You should also note that IPv6 features have appeared in multiple
versions; HostnameEndpoint was added in 13.2.0 for example, whereas
basic "connectTCP to IPv6 address" was added in 12.1.0, with listenTCP
in 12.0.0
So:
import twisted
vt = (twisted.version.major, twisted.version.minor)
if vt > (13,2):
def connectv6name(n):
return HostnameEndpoint(...)
elif vt > (12,1):
def connectv6name(n):
d = myGetAddrInfo(...)
d.addCallback(reactor.connectTCP, ...)
else:
def connectv6name(n):
raise Exception('twisted too old for IPv6')
More information about the Twisted-Python
mailing list