Hey guys! So I recently started exploring the InetAddress object, and came across 2 methods which confused me: getHostName()
and getCanonicalHostName()
. I don't fully understand the difference between a canonical host name (fqdn) and a general host name, so if someone could explain the distinction to me in detail that would be awesome!
Also, I am writing a program where I want the value returned from a method to be the same when the program is run from any computer on the network, but if the program is run from a computer off the network it would return a different result. Should I be using getHostName() or getCanonicalHostName() to differentiate one network from another, and why?