Used getaddrinfo in place of gethostbyname.