|
string testDNS(string dns) {
int WSA_return;
WSADATA WSAData;
WSA_return = WSAStartup(0x0101, &WSAData);
HOSTENT* host_entry;
string aaa;
host_entry = gethostbyname(dns.c_str());
if (host_entry)
{
int i1 = host_entry->h_addr_list[0][0] & 0x00ff,
i2 = host_entry->h_addr_list[0][1] & 0x00ff,
i3 = host_entry->h_addr_list[0][2] & 0x00ff,
i4 = host_entry->h_addr_list[0][3] & 0x00ff;
char tmp[32];
sprintf_s(tmp, "%d.%d.%d.%d", i1, i2, i3, i4);
aaa = tmp;
}
WSACleanup();
return aaa;
}
|
|