NetworkInterface.getNetworkInterfaces() - problem...

Simba simba87@arcor.de
Thu Dec 6 00:35:00 GMT 2007


Hello!
First of all - I'm really new to all this, so if I'm overlooking 
something, please tell me.
I tried to cross-compile a more recent build of GCJ for Windows (under 
Linux) but failed. So, I'm sticking to the thisiscool.com version 4.3 
gcj-eclipse-merge branch (thanks to Mohan I'm able to use GCJ under 
Windows in the first place!).
Perhaps it is already fixed - if so, please let me know.
I have some problems with the NetworkInterface class. The code:
------
while(interfaces.hasMoreElements()) {
 NetworkInterface ni=interfaces.nextElement();
 System.out.print(ni.getName() + ": " + ni.getDisplayName() + ", ");
 Enumeration <InetAddress>addresses=ni.getInetAddresses();
 while(addresses.hasMoreElements()) {
 System.out.print(addresses.nextElement().getHostAddress());
 }
 System.out.println();
}
------
gives different results from javac and gcj.
GCJ:
 lo: lo, 127.0.0.1
 eth1: eth1, 192.168.1.6
 eth0: eth0, 192.168.166.1
javac:
 lo: MS TCP Loopback interface, 127.0.0.1
 eth0: VMware Virtual Ethernet Adapter for VMnet1, 192.168.166.1
 eth1: NVIDIA nForce Networking Controller - Paketplaner-Miniport,
 eth2: Broadcom 802.11-Multiband-Netzwerkadapter - 
Paketplaner-Miniport, 192.168.1.6
As you can see, there're 3 problems.
 >First thing: GCJ's eth1 != Sun's eth1. This is a big problem for me, 
because one of my program writes properties concerning one specific 
interface to a file which is read by the natively compiled program. But 
as neither the the display names (from getDisplayName()) nor the 
physical interface name match, it turns out to be not possible to 
clearly indicate a specific interface by a name.
 >Second thing: GCJ only returns interfaces that have an actual IP 
(which is problematic because you can not say whether the interface does 
exists and has no IP or isn't existent at all).
 >Third problem: getDisplayName() returns no display name ;)
If this is already fixed, could you please compile a current version, 
Mohan? That would be really nice :)
Thanks in advance and greets,
Simba


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /