我如下使用getaddrinfo函数,
struct addrinfo hints,*res;
hints.ai_family=AF_INET;
hints.ai_flags = AI_PASSIVE;
hints.ai_socktype = 0;
hints.ai_protocol = 0;
getaddrinfo(NULL,"0",&hints,&res);
为什么得不到res的返回值,总是出现执行错误
struct addrinfo hints,*res;
hints.ai_family=AF_INET;
hints.ai_flags = AI_PASSIVE;
hints.ai_socktype = 0;
hints.ai_protocol = 0;
getaddrinfo(NULL,"0",&hints,&res);
为什么得不到res的返回值,总是出现执行错误
struct addrinfo hints,*res;
memset(&hints,0,sizeof(hints));
hints.ai_family=AF_UNSPEC;
getaddrinfo(NULL,"0",&hints,&res);
我用这种方法返回res,然后调用
bind(sock,res->ai_addr,res->ai_addrlen);
这么返回的res值有什么意义?我用单步调用发现res中的ai_addr字段都是0,ai_addrlen为16。
bind函数绑定的是什么地址?