Say I call getaddrinfo() as below:
addrinfo hints;
addrinfo* res = NULL;
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
getaddrinfo(NULL, "http", &hints, &res);
Is it currently possible for the results of this to contain more than one result with an IPv4 address? The only reason I could think of is possibly multiple devices with separate connections, but I’m half expecting it to only return the address of the primary connection or the one connection it happens to use.
Yes.
The man page on getaddrinfo has following to say on the topic
There are several reasons why the linked list may have more than one addrinfo structure, including: the network host is multihomed, accessible over multiple protocols (e.g. both AF_INET and AF_INET6); or the same service is available from multiple socket types (one SOCK_STREAM address and another SOCK_DGRAM address, for example). Normally, the application should try using the addresses in the order in which they are returned. The sorting function used within getaddrinfo() is defined in RFC 3484; the order can be tweaked for a particular system by editing /etc/gai.conf (available since glibc 2.5).