fixing handling of errors from getaddrinfo