C++ (Qt)void DomainToIP(const char* iDomainAddress, UInt32 & oIPAddress){ struct hostent * hostinfo = gethostbyname(iDomainAddress); if (hostinfo) oIPAddress = *(reinterpret_cast<UInt32*>(hostinfo->h_addr_list[0])); else throw BadNameException(); oIPAddress = ntohl(oIPAddress);}
C++ (Qt)void DomainToIP(const char* iDomainAddress, UInt32 & oIPAddress){ struct hostent * hostinfo = gethostbyname(iDomainAddress); if (hostinfo) oIPAddress = *(reinterpret_cast<UInt32*>(hostinfo->h_addr_list[0])); else { struct addrinfo * result = 0; int error = getaddrinfo(iDomainAddress, NULL, NULL, &result); if (!error && !result) error = -1; if (!error) oIPAddress = *(reinterpret_cast<UInt32*> (result->ai_addr->sa_data + 2)); if (result) freeaddrinfo(result); if (error || oIPAddress == 0) throw BadNameException(); } oIPAddress = ntohl(oIPAddress);}