[Twisted-Python] twisted.internet and IPv6

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Mon Oct 18 08:51:37 EDT 2004

exarkun at divmod.com schrieb:
 > On Thu, 30 Sep 2004 10:12:18 +0200, Stefan Behnel <behnel_ml at gkec.informatik.tu-darmstadt.de> wrote:
 >>I'm curious: how much work would it be to enable IPv6 support in twisted.internet?
 >   Not very much.  About a year ago, I wrote this:
 >     http://cvs.twistedmatrix.com/cvs/trunk/sandbox/exarkun/ipv6.py?view=markup&rev=10540&root=Twisted
 >   This is no longer how I'd like to see IPv6 supported in Twisted, but it gives an idea of how few changes are required.

That really doesn't seem to be a big change in the current code base. It's not very object oriented, though, so as you said, it would have to be rewritten to integrate it with Twisted.

However, I think the address handling would be a thing worth generalizing. I found this on the web:


I already had to adapt it a bit as some code parts are somewhat clumsy, but I find it a nice abstraction for IP addresses. If such a thing was part of Twisted, the interfaces for handling IPv[46] could become completely transparent.

You could even cut them into the existing interfaces:

from IPy import IP
def connectTCP(host, port, ...)
   if isinstance(host, str):
     ... # use original IPv4 implementation - or convert host to IP(host)
   elif isinstance(host, IP):
     ... # connect either with IPv4 or IPv6, depending on host.version()


More information about the Twisted-Python mailing list