Try replacing gethostbyname with getaddrinfo/search-for-nonlocal