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?

Very consise :) But if you could give me a more detailed explanation of what the two are, that would be great. Also, which should I use to differentiate one network from another, and why?

(If someone can answer this post in more detail than masijade that would be swell)

Research some basic networking. If you are writing a program that deals with a subject, you need someone physically working with you that understands that subject, and it is best if that person is you.

Edited 5 Years Ago by masijade: n/a

I did research the subject, and I came across something I didn't understand, hence I posted my question here. Telling me to go back and research isn't going to help me reach my goal -- if you can either answer my question so I can continue with my researching or otherwise point me in the direction toward my answer rather than a vague gesture toward google.com, then I could better achieve my objective. And I'd like to draw a distinction between someone who shows up and says "solve my homework for me" and someone who shows up and says "I don't understand this concept." Only the first warrants a flippant "go figure it out yourself."

Use the full one always and if the domain part is the same simply don't show it. Or, if you wish, if the domain part is the same then use the other. That is the only simple solution. Better would be to actually check their addresses, not their names.

Edit: And, p.s., I said understand the subject, not just have a fleeting, surface, familiarity with it.

Edit Again: Their addresses in combination with their netmasks (all of them), of course, as that is what will tell you if they are really part of the same network(s). You do know what that means, right? That does not mean, however, that they either can or cannot reach each other without using the fqdn, the host table and local nis/dns servers is what will determine that.

Edited 5 Years Ago by masijade: n/a

Actually I wasn't familiar with what a netmask was, but now that you have told me to make sure that that they match up as well I will research what they are and how to do that. So thank you :)

And I certainly agree -- a true comprehension of a subject is much better than understanding just what you need to get by. And ultimately that's what I'm striving for. But at the moment I am still testing the waters with understanding networks, but hopefully as I learn more I will better understand how they work. Nevertheless, thank you for your help just now ^.^ I was looking for a response like that one.

This article has been dead for over six months. Start a new discussion instead.