[Python-3000] IPv6 address tuple

Jun-ichiro itojun Hagino itojun at itojun.org
Tue Apr 3 08:54:57 CEST 2007


> | > 	i understand your concern.  current 4-tuple is direct mapping from
> | > 	struct sockaddr_in6 (which has those two additional members).
> | 
> | 	note however, you must rewrite DNS resolving from gethostby* to
> | 	get*info anyways, so i'm not too sure if the number of tuple members in
> | 	sockaddr matters that much.
> 
> This is true when using explicit DNS resolving, but Python socket API
> allows you to pass in a string in place of the address in the tuple,
> and then resolves it to an address behind your back. This
> is probably the most common way of using DNS in Python.
> 
> It seems that when you have an AF_INET6 socket, it looks for
> an AAAA record, and when you have an AF_INET socket, it goes for A.

	hmm.  how would Python behave when there are multiple AAAA (or A)
	records?  just pick the first one?

> Unfortunately this bumps the address family-agnostic get*info API
> to second place in the convenience-of-use competition
> (getaddrinfo example at <http://docs.python.org/lib/socket-example.html>).

	with mixed IPv4/v6 environment (this would be the network environment
	for today and coming decade(s)), a program should try to connect both
	A and AAAA records, since connectivity situation varies by
	configuration such as network configuration, kernel compilation options
	and so forth.
	for this reason it would be better (or i might say we have to)
	for all libraries (like HTTP, FTP, and stuff) as well as user
	applications to use get*info API, instead of just building a tuple and
	then use AF_INET/6 socket.

itojun


More information about the Python-3000 mailing list