Le 2014-05-02 10:48, Jérémie Courrèges-Anglas a écrit :
> Let's say you have a machine with no IPv6 address configured (or rather,
> only link-local addresses configured and ::1 on lo0). With the
> AI_ADDRCONFIG flag (either set explicitely or assumed if the caller
> passes no hints structure):
> 
> - getaddrinfo("fe80::...%em0") fails with "no address associated with name"
> - getaddrinfo("::1") fails similarly
> - more generally, getaddrinfo("numeric IPv6 address") fails with "no
>   address associated with that name"
> - getaddrinfo("localhost") now requires IPv4/v6 connectivity on non-lo
>   interfaces.  oops.
> 
> All those are IMHO poor behavior (lies), especially since getaddrinfo is
> supposed to handle pretty much anything you're throwing at it.

I think you need to change your expectations.

If you're running on a host without IPv6, why would you want
getaddrinfo() to return any IPv6 results? What good would it do to you?

AI_ADDRCONFIG is all about what it *returns*. The fact that it allows
skipping DNS AAAA requests is a nice side-effect.

If your program needs to resolve addresses for the sake of resolving
addresses, and you want accuracy, you need to explicitly unset
AI_ADDRCONFIG. You're writing something special. In the general case,
where you will just connect() or bind() on the returned addresses,
AI_ADDRCONFIG makes sense as is.

Has this caused any real-world problems?

Simon

Reply via email to