Unix网络编程 第11章 Name and Address Conversions 笔记
# gethostbyname 和 gethostbyaddr 用来在 IPv4 地址和 hostname 之间转换. getservbyport 和 getservbyname 则是与服务相关。gethostbyname出错时不设errno而是设h_errno,并有hstrerror()函数。 # FQDN的全称是: Fully Qualified domain name. 技术上说必须以点号(period)终止. # AAAA 被称为 “quad A” rcord, 给出了从hostname到Ipv6地址的映射。 PTR用来把IP地址到hostname. # Entries in the DNS are known as Resource Records(RRs). # 一个点分十进制(dotted-decimal)IPv4的地址前加 0::ffff:就是 IPv6的字符串形式。 # 与getpeername对应的函数不是gethostname而是getsockname. # getaddrinfo函数的host参数指定为dotted-decimal IPv4或 IPv6 hex string,会使得只有IPv4或IPv6的addrinfo返回。 # 不给UDP套接字设置SO_REUSEADDR选项。We do not set the SO_REUSEADDR socket option for the UDP socket because this socket option can allow multiple sockets to bind the same UDP port on hosts that support multicasting. Since there is nothing like TCP’s TIME_WAIT state for a UDP socket, there is no need to set this socket option when the server is started. ...