getaddrinfo() API 有谁知道什么意思
struct addrinfo* CProtoInfo::ResolveAddress(char* addr, char* port, int af, int type, int proto)
{
struct addrinfo hints;
struct addrinfo* res = NULL;
int rc = 0;
memset(&hints, 0, sizeof(hints)); //初始化结构体hints
hints.ai_flags = (NULL != addr ? 0 : AI_PASSIVE);
hints.ai_family = af;
hints.ai_socktype = type;
hints.ai_protocol = proto;
if(0 != getaddrinfo(addr, port, &hints, &res))
{
return NULL;
}
else
{
return res;
}
}
getaddrinfo() 这个API 参数 1,参数2 ,参数3,参数4. 查了百度和MSDN了,但是说法都太高大上。并不是没看,只是实在没理解他们意思。来个能通俗的说法。