Beej\'s Simple Client example code iterates over all IP addresses returned from getaddrinfo(), until it can connect to the first one. See the code below.
Yes, you should loop through all of them -- there's no guarantee that the first one (or whatever you pick) of the addresses will actually be valid. That's why it's done like that in the tutorial.