64 struct addrinfo hints, *res;
67 memset(&hints, 0,
sizeof(hints));
68 hints.ai_family = AF_INET;
69 hints.ai_socktype = SOCK_STREAM;
70 hints.ai_flags = AI_PASSIVE;
73 gethostname(hostname,
sizeof(hostname));
74 if (getaddrinfo(hostname, NULL, &hints, &res) != 0) {
75 perror(
"getaddrinfo 실패");
79 struct sockaddr_in *ipv4 = (
struct sockaddr_in *)res->ai_addr;
80 inet_ntop(AF_INET, &(ipv4->sin_addr), net_info.
ip, INET_ADDRSTRLEN);
81 net_info.
family = res->ai_family;