🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #1704

Re: [java] alle IP adressen opvragen

#1704
From: mortician
Date: Tue, 14 Dec 2004 10:30
35 lines
2295 bytes
On Tue, 14 Dec 2004 10:12:48 +0000, Passero wrote:

> 
> "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();


          Enumeration en2 = temp.getInetAddresses();
          while (en2.hasMoreElements()) {
           InetAddress address = (InetAddress)en2.nextElement();
           System.out.println(address.getHostAddress());
          }


>       }
>     }
>     catch (SocketException ex) {ex.printStackTrace();}
>     catch(UnknownHostException ex){ex.printStackTrace();}
Technical Details
Message-ID: <pan.2004.12.14.10.30.56.535165@lacerta.be>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsgate.cistron.nl!skynet.be!skynet.be!ossa.telenet-ops.be!hebe.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> <A0zvd.20001$4y4.955461@phobos.telenet-ops.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!news4.google.com!news.glorb.com!newsgate.cistron.nl!skynet.be!skynet.be!ossa.telenet-ops.be!hebe.telenet-ops.be.POSTED!not-for-mail
From: mortician <mortician_NOSPAM_@lacerta.be>
Subject: Re: [java] alle IP adressen opvragen
User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)
Message-ID: <pan.2004.12.14.10.30.56.535165@lacerta.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> <A0zvd.20001$4y4.955461@phobos.telenet-ops.be>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
Lines: 36
Date: Tue, 14 Dec 2004 10:30:51 GMT
NNTP-Posting-Host: 213.224.182.170
X-Complaints-To: abuse@telenet.be
X-Trace: hebe.telenet-ops.be 1103020251 213.224.182.170 (Tue, 14 Dec 2004 11:30:51 CET)
NNTP-Posting-Date: Tue, 14 Dec 2004 11:30:51 CET
Organization: Telenet Internet