Linux2020. 9. 7. 15:35[Linux, C] IP주소와 도메인네임을 서로 치환하는 프로그램 TCP/IP통신

#include #include #include #include #include #include int main(int argc, char **argv){ struct hostent *host; struct sockaddr_in addr; int i; // 메모리 초기화 memset(&addr, '0', sizeof(addr)); // 인자 수 체크 if(argc!=2){ printf("Please, Input IP Address or Domain Name \n"); exit(1); } // 32비트 IPv4주소를 넣을 수있다. inet_addr()를 통해 32비트 변환 addr.sin_addr.s_addr=inet_addr(argv[1]); // addr : inet_addr()한수를 이용해 변환된 I..

image