大家
好,我试图从我的 res 结构中获取 IP 地址,但我仍然无法通过它,有人知道如何获取它们吗?
int main(int argc, char **argv) {
struct addrinfo hints, *res;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_PASSIVE;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if(getaddrinfo(NULL, "50000", &hints, &res) != 0) {
perror("Error in getaddrinfo\n");
exit(-1);
}
//Print out the IPs from res
return 0;
}