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')

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to