【发布时间】:2011-11-03 19:47:20
【问题描述】:
任何帮助将不胜感激。我正在开发一个 udp 连接,并且我有一个初始化地址参数的函数。 这是代码
void Socket::InitAddrInfoStruct (struct addrinfo *hints, bool socktype){
/* Setting addrinfo struct */
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC; // set to AF_INET to force IPv4
if(socktype == true)
hints.ai_socktype = SOCK_DGRAM; // set to SOCK_DGRAM to force UDP protocol type
else
hints.ai_socktype = SOCK_STREAM; // set to SOCK_STREAM to force TCP protocol type
hints.ai_flags = AI_PASSIVE; // use my IP
}
当我尝试编译时,出现以下错误: 在“hints”中请求成员“ai_family”,它是非类类型“addrinfo*”
谁能帮助我如何将数据添加到结构提示中?
【问题讨论】: