IPv6 and Python

Christian Heimes lists at cheimes.de
Fri May 2 15:46:54 EDT 2008


Giampaolo Rodola' schrieb:
> I'm not sure if this is a question about python programming, system
> administration or sockets in general...
> I have the FTP server in my signature to which I'd want to add IPv6
> support.
> My hosting company provides me a common IPv4 address.
> I'd like to set up my workstation (Windows XP or Linux Debian, doesn't
> really matter) to temporarily use IPv6 for trying to add such feature
> to my library (I work on both Windows XP and Linux).
> Could someone point me to some resources describing how could I do
> that?

Python supports IPv6 out of the box if the underlying OS supports it,
too. You just have to use AF_INET6 instead of AF_INET:

import socket
sock = socket.socket(sock.AF_INET6, socket.AF_STREAM) # IPv6
sock.bind(("::1", 21)) # bind to IPv6 localhost

That's it.

Christian




More information about the Python-list mailing list