InetAddress question

R

Rhino

I am dabbling with the InetAddress class. Can anyone tell me why/when the
getAllByName() method in that class would ever return more than one value?

I'm trying to figure out if using getByName() will be sufficient for all but
the most obscure situations or whether it is safer to use getAllByName()
every time.

--
Rhino
---
rhino1 AT sympatico DOT ca
"There are two ways of constructing a software design. One way is to make it
so simple that there are obviously no deficiencies. And the other way is to
make it so complicated that there are no obvious deficiencies." - C.A.R.
Hoare
 
T

Tilman Bohn

I am dabbling with the InetAddress class. Can anyone tell me why/when the
getAllByName() method in that class would ever return more than one value?

When there is more than one IP address, or more precisely, more than
one A record for that hostname -- so-called multi-homed hosts. For
example, do an nslookup www.yahoo.com. (Actually, in this case there is
only a CNAME record aliasing www.yahoo.com to www.yahoo.akadns.net, and
then there are half a dozen A records for that name. But you can ignore
that additional level of indirection for this discussion, as it's
handled transparently for you by your resolver, and consequently by
the InetAddress class.)
I'm trying to figure out if using getByName() will be sufficient for all but
the most obscure situations or whether it is safer to use getAllByName()
every time.

It depends on what you need to do and how resilient you want or need
to be against failures.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top