Detecting multiple IPs

s_lavie
s_lavie used Ask the Experts™
on
I have a machine with 3 active ip addresses defined on it.
There is only one network card on that machine - does it matter?

I tried to discovered all three by using:

InetAddress[] hosts = InetAddress.getAllByName(InetAddress.getLocalHost().getHostAddress());

Nevertheless, hosts.length == 1

Why?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Out of curiousity, how can you simultaneously have three active IP adresses on the same network card?
Mick BarryJava Developer
Top Expert 2010

Commented:
And what is the address it's returning?

Author

Commented:
> Out of curiousity, how can you simultaneously have three active IP adresses on the same network card?
You just add IP address (at least on win2000 it works...)
> And what is the address it's returning?
The first IP it finds.

Anyway I managed to get all IPs by using:
InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());

Thanks anyway....
Commented:
PAQ'd and 50 points refunded

modulo

Community Support Moderator
Experts Exchange

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial