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.
Assuming you are new to socket, at this point. Yes, it is crucial because after using getaddrinfo, you can retrieve a address info for further validation.