🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #1703

Re: [java] alle IP adressen opvragen

#1703
From: Passero
Date: Tue, 14 Dec 2004 10:12
26 lines
2007 bytes
"mortician" <mortician_NOSPAM_@lacerta.be> schreef in bericht
news:pan.2004.12.13.18.58.12.406376@lacerta.be...
> On Mon, 13 Dec 2004 18:19:06 +0000, Passero wrote:
>
> > Via de klasse InetAddress kan je het ip opvragen van de localhost maar
als
> > je nu een pc hebt met meerdere interfaces, hoe kan je dan alle IP's
> > opvragen?
>
> kijk eens naar de klasse NetworkInterface ;)

Heb ik nu gedaan en dit blijkt niet echt te werken, wat doe ik fout?

try
    {
      Enumeration en = NetworkInterface.getNetworkInterfaces();
      while(en.hasMoreElements())
      {
        NetworkInterface temp = (NetworkInterface)en.nextElement();
        InetAddress adr = InetAddress.getByName(temp.getName());
        System.out.println(adr.getLocalHost().getHostAddress());
      }
    }
    catch (SocketException ex) {ex.printStackTrace();}
    catch(UnknownHostException ex){ex.printStackTrace();}
Technical Details
Message-ID: <A0zvd.20001$4y4.955461@phobos.telenet-ops.be>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!newsfeed.icl.net!newsfeed.arcor.de!feed1.news.be.easynet.net!ossa.telenet-ops.be!phobos.telenet-ops.be.POSTED!not-for-mail
References: <u2lvd.19201$Og7.929860@phobos.telenet-ops.be> <pan.2004.12.13.18.58.12.406376@lacerta.be>

Show Full Headers
Complete Article Headers
X-Google-Thread: fcea4,2cd478ce225afbb1
X-Google-Thread: 107324,2cd478ce225afbb1
X-Google-Attributes: gidfcea4,gid107324,public
X-Google-Language: DUTCH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!newsfeed.icl.net!newsfeed.arcor.de!feed1.news.be.easynet.net!ossa.telenet-ops.be!phobos.telenet-ops.be.POSTED!not-for-mail
From: "Passero" <bla@bla.be>
Newsgroups: be.comp.programming,nl.comp.programmeren
References: <u2lvd.19201$Og7.929860@phobos.telenet-ops.be> <pan.2004.12.13.18.58.12.406376@lacerta.be>
Subject: Re: [java] alle IP adressen opvragen
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <A0zvd.20001$4y4.955461@phobos.telenet-ops.be>
Date: Tue, 14 Dec 2004 10:12:48 GMT
NNTP-Posting-Host: 84.194.212.59
X-Complaints-To: abuse@telenet.be
X-Trace: phobos.telenet-ops.be 1103019168 84.194.212.59 (Tue, 14 Dec 2004 11:12:48 MET)
NNTP-Posting-Date: Tue, 14 Dec 2004 11:12:48 MET
Organization: Telenet Internet