Archived

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

MadProgrammer

Doing a DNS Resolve in C++

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
      
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