#include <winsock.h>
#pragma comment(lib, "ws2_32.lib")
void init_ws() {
WSADATA WSAData;
WSAStartup (MAKEWORD(2,2), &WSAData);
}
char* get_ip(const char* domain) {
struct hostent *host_entry;
host_entry = gethostbyname(domain);
char* ip = inet_ntoa( *(struct in_addr*)host_entry->h_addr_list[0]);
return ip;
}
int _tmain(int argc, _TCHAR* argv[])
{
init_ws();
char *ip = get_ip("www.freelab.co.kr");
printf("ip=%s\n", ip);
return 0;
}
No comments:
Post a Comment