This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: java.net.NetworkInterface
- From: Michael Koch <konqueror at gmx dot de>
- To: Erik Poupaert <erik dot poupaert at chello dot be>
- Cc: java at gcc dot gnu dot org
- Date: Sat, 21 Jun 2003 10:19:41 +0200
- Subject: Re: java.net.NetworkInterface
- References: <20030621031718.4e3562a7.erik.poupaert@chello.be>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am Samstag, 21. Juni 2003 05:17 schrieb Erik Poupaert:
> I finally found a way to figure out network ip address for
> localhost:
>
> protected static String getHostIpAddress()
> {
> try
> {
> Enumeration
> networkInterfaces=NetworkInterface.getNetworkInterfaces(); for
> (Enumeration e = NetworkInterface.getNetworkInterfaces() ;
> e.hasMoreElements() ;)
> {
> NetworkInterface netIf=(NetworkInterface)e.nextElement();
> for(Enumeration e2=netIf.getInetAddresses();
> e2.hasMoreElements();) {
> InetAddress address=(InetAddress)e2.nextElement();
> String ip=address.getHostAddress();
> //grab the first non-loopback address
> if(!ip.equals("127.0.0.1")) return ip;
> }
> }
> throw new RuntimeException("error resolving localhost ip
> address"); }
> catch(Exception e)
> {
> throw new RuntimeException(e.getMessage());
> }
> }
>
> It works fine on linux: gcc version 3.3 release.
>
> On Windows, however (gcc version 3.3 20030409 (prerelease),
> NetworkInterface.getNetworkInterfaces() indiscriminately throws a
> java.net.SocketException.
>
> Does anybody know if this problem has been solved after 20030409 in
> Windows? Could I avoid this by downloading Mohan's latest build?
This stuff isnt implemented yet for Windows but I know Mohan is
working on this. I've seen no patch from him yet but I think it will
not take much longer.
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+9BUdWSOgCCdjSDsRAopwAKCS//PlMmMTq2VVzkr050OyndwGbACfTk6U
eCTCPq1z4Wfsrw2NRz7IPUA=
=V6zd
-----END PGP SIGNATURE-----