When you give NULL
as hints, getaddrinfo will automatically use AI_ADDRCONFIG
. Usually you'd want that flag set, but when connecting to a link local address is the one case where you don't want it.
I'm guessing you don't have a global IPv6 address configured and AI_ADDRCONFIG
therefore selects only IPv4, not IPv6. Providing proper hints is the way to avoid this.