All pastes #20600 Raw Edit

Stuff

public text v1 · immutable
#20600 ·published 2005-08-21 02:13 UTC
rendered paste body
std::string dns(std::string a){
		
		struct hostent *host;
        WSADATA wsaData; 
		if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
			return "Winsock failed to start up... what did you expect?";
        }
		
        if ((host=gethostbyname(a.c_str())) == NULL) {  // get the host info
            return "Could not get to host for some reason.";
        }

        
		return std::string(inet_ntoa(*((struct in_addr *)host->h_addr)));
}