diff --git a/Socket.xs b/Socket.xs index cceead3..b11ea75 100644 --- a/Socket.xs +++ b/Socket.xs @@ -745,34 +745,20 @@ inet_aton(host) char * host CODE: { -#ifdef HAS_GETADDRINFO - struct addrinfo *res; - struct addrinfo hints = {0,}; - hints.ai_family = AF_INET; - if (!getaddrinfo(host, NULL, &hints, &res)) { - ST(0) = sv_2mortal(newSVpvn( - (char *)&(((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr), - 4 - )); - freeaddrinfo(res); - XSRETURN(1); - } -#else struct in_addr ip_address; struct hostent * phe; + if ((*host != '\0') && inet_aton(host, &ip_address)) { ST(0) = sv_2mortal(newSVpvn((char *)&ip_address, sizeof(ip_address))); XSRETURN(1); } #ifdef HAS_GETHOSTBYNAME - /* gethostbyname is not thread-safe */ phe = gethostbyname(host); if (phe && phe->h_addrtype == AF_INET && phe->h_length == 4) { ST(0) = sv_2mortal(newSVpvn((char *)phe->h_addr, phe->h_length)); XSRETURN(1); } #endif -#endif XSRETURN_UNDEF; }