Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MadProgrammer

Doing a DNS Resolve in C++

This topic is 6029 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

how do i resolve a name (gamedev.net) to its ip (66.28.17.130)? i have tried using the hostent structure, but it doesnt work for me. Could someone post some code that works? i have searched through gamedev, and have not found anything that works. Please help

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
gethostbyname

Share this post


Link to post
Share on other sites
      
bool Lookup(LPCTSTR lpHost, LPTSTR lpAddr)
{
HOSTENT *pHost;
pHost = gethostbyname(lpHost);

if(pHost == NULL){
return false;
}
unsigned char *chAddr = (unsigned char *)pHost->h_addr_list[0];

_stprintf(lpAddr, _T("%d.%d.%d.%d"), chAddr[0], chAddr[1], chAddr[2], chAddr[3]);
return true;
}



Edited by - jonstelly on December 15, 2001 5:21:26 PM

Share this post


Link to post
Share on other sites
dangit!!! i had it all the time, but i was trying to print out (char*)pHost->h_addr_list[0]. it would give 4 wierd chars & then the name i was trying to look up! i thought it would be a string it put in h_addr_list. Thanks!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!