(#6) Address preference
You might not be aware of it, but your system has an address preference. That means, when DNS comes back with more than one IP address, getaddrinfo() will order these addresses in its returned address list based on this preference. In this video, the address preference algorithms is explained on a very high level, i.e. a lot of the gory details of that algorithm is left out.
ipv4