| |

VerySource

 Forgot password?
 Register
Search
View: 590|Reply: 0

DNS domain name resolution

[Copy link]

1

Threads

1

Posts

0.00

Credits

Newbie

Rank: 1

Credits
0.00

 China

Post time: 2020-11-9 17:11:05
| Show all posts |Read mode
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;
}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list