Host Name Vs Canonical Host Name

前端 未结 1 1762
时光说笑
时光说笑 2021-02-05 03:00

Can anyone please explain me the difference between Host Name and Canonical Host Name?

I am currently using InetAddress class to fetch host name using the IP Address. I

1条回答
  •  一整个雨季
    2021-02-05 03:33

    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.

    0 讨论(0)
提交回复
热议问题