Doing a DNS Resolve in C++
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement