【发布时间】:2011-05-11 03:11:56
【问题描述】:
struct addrinfo *myAddrinfo, *curMyAddrinfo, hint;
memset(&hint, 0, sizeof(struct addrinfo));
hint.ai_family = AF_INET;
hint.ai_protocol = AI_PASSIVE;
hint.ai_socktype = SOCK_STREAM;
const int code = getaddrinfo(NULL, SERVER_PORT, &hint, &myAddrinfo);
if ((code) != 0) {
printf("getaddrinfo error occours: %s ",
gai_strerror(code));
return 1;
}
这给出了错误:“ai_socktype not supported”
如果我注释掉hint.ai_protocol = AI_PASSIVE; 它会通过,但我想知道为什么会这样?
感谢您的宝贵时间
【问题讨论】:
标签: c sockets network-programming getaddrinfo