getaddrinfo(),gethostbyname(),getnetbyaddr(),getservbyname(),getprotobyname()对比总结

1. gethostbyname()

原理:查询 /etc/hosts 等文件及 DNS or NIS 服务器
The  domain  name  queries carried out by gethostbyname() and gethostbyaddr() use a combination of any or all of the name server named(8), a broken out line from/etc/hosts, and the Network Information Service (NIS or YP), depending upon the contents of the order line in /etc/host.conf.  The default  action  is  to  query named(8), followed by /etc/hosts.(ubuntu man page)
The network configuration information returned by these functions can be kept in a number of places. They can be kept in static files (/etc/hosts, /etc/services, etc.), or they can be managed by a name service, such as DNS (Domain Name System) or NIS (Network Information Service). (APUE-2e)

见 http://blog.csdn.net/duyiwuer2009/article/details/7861938 的分析


2. getaddrinfo()

原理:可以确定的是其实现与 gethostbyname() 中涉及的 /etc/hosts 等文件及 DNS 有关,还与 /etc/services 有关(APUE-2e中 ruptime 的例子就可以说明这一点)

见 http://blog.csdn.net/duyiwuer2009/article/details/7875206 的分析

其它参考资料:

UNIX Network Programming Volume 1, Third Edition 


3. getnetbyaddr()

原理:The getnetent() function reads the next entry from the networks database(/etc/networks)

见 http://blog.csdn.net/duyiwuer2009/article/details/7861938 的分析


4. getservbyname()

原理: The getservent() function reads the next entry from the services database(/etc/services)

见 http://blog.csdn.net/duyiwuer2009/article/details/7871939 的分析


5、getprotobyname()

原理:The  getprotoent() function reads the next entry from the protocols database(/etc/protocols)

见 http://blog.csdn.net/duyiwuer2009/article/details/7872121 的分析


你可能感兴趣的:(function,service,database,domain,NetWork,protocols)