addrinfo的结构体

struct addrinfo
{
  int ai_flags;
  int ai_family; //AF_INET,AF_INET6,UNIX etc
  int ai_socktype; //STREAM,DATAGRAM,RAW
  int ai_protocol; //IPPROTO_IP, IPPROTO_IPV4, IPPROTO_IPV6 etc
  size_t ai_addrlen;//length of ai_addr
  char* ai_canonname; //full hostname
  struct sockaddr* ai_addr; //addr of host
  struct addrinfo* ai_next;
}

参数
取值
说明
ai_family
AF_INET
2
IPv4
AF_INET6
23
IPv6
AF_UNSPEC
0
协议无关
ai_protocol
IPPROTO_IP
0
IP协议
IPPROTO_IPV4
4
IPv4
IPPROTO_IPV6
41
IPv6
IPPROTO_UDP
17
UDP
IPPROTO_TCP
6
TCP
ai_socktype
SOCK_STREAM
1
SOCK_DGRAM
2
数据报
ai_flags
AI_PASSIVE
1
被动的,用于bind,通常用于server socket
AI_CANONNAME
2
用于返回主机的规范名称
AI_NUMERICHOST
4
地址为数字串

你可能感兴趣的:(c++)