== What Linux's _getaddrinfo()_ is doing with IPv6 (on some versions) I've previously noted that Linux's _getaddrinfo()_ implementation doesn't return IPv6 addresses by default if it doesn't think that your system is IPv6 capable, or perhaps if your system has IPv6 disabled (this is most conveniently visible through the [[Python interface ../python/UsingGetaddrinfo]]). This behavior is more or less the same as what you'd get if you supplied the ((AI_ADDRCONFIG)) flag in the _hints_ structure. (To be specific, I have seen this behavior on Ubuntu 8.04. It doesn't seem to be present in Ubuntu 6.06, and unfortunately I don't have any other Linux machines with IPv6 disabled to test on.) This behavior is half-documented in [[modern _getaddrinfo()_ manpages http://manpages.courier-mta.org/htmlman3/getaddrinfo.3.html]], which say that if you supply no _hints_ structure you get flags that include ((AI_ADDRCONFIG)). However this is not the full story, since you also get this behavior if you supply a _hints_ structure with ((ai_family)) set to 0 (aka ((AF_UNSPEC))). I would love to report that I had found the code that does this in glibc. However, the glibc _getaddrinfo()_ internals have defeated me; I cannot see any clear code that has this particular side effect. So all I can do is report what I have determined experimentally, which is that supplying a non-zero set of flags in ((af_flags)) doesn't make a difference, nor does the type of socket you ask for. The only thing that will get you IPv6 addresses on such a Linux system is putting ((AF_INET6)) in the ((ai_family)) field, at which point they will magically appear. (Note that this behavior is subtly different from turning on the ((AI_ADDRCONFIG)) flag all the time, as the flag causes IPv6 results to never get returned, even if you ask for them specifically.) I assume that this is why '_getents ahostsv6_' (from the comments [[here ../python/GetaddrinfoForIps]]) will fail on such a system; I expect it is making a plain _getaddrinfo()_ call and filtering the results if you ask specifically for IPv6 addresses. (The _getents_ behavior may be a bug, but the glibc _getaddrinfo()_ behavior is probably deliberate.)