Host Name Vs Canonical Host Name

早过忘川 提交于 2019-12-03 04:29:23

There are a few difference between the two:

  • getCanonicalHostName() will attempt to resolve the FQDN. Therefore, you would get foo.mycompany.com whereas getHostName() might just return foo.

  • getCanonicalHostName() will always do a reverse DNS lookup, whereas getHostName() would return the stored hostname if you supplied one in the InetAddress constructor.

I suspect you will be wanting to use getCanonicalHostName() if you are intending to map IP addresses to host names.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!