Doing a DNS Resolve in C++

Started by
2 comments, last by MadProgrammer 22 years, 4 months ago
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
Advertisement
gethostbyname
      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
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!

This topic is closed to new replies.

Advertisement