Selecting an ip from the getaddrinfo list
Checking for socket errors