harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paulex Yang <paulex.y...@gmail.com>
Subject Re: [luni][net] NetworkInteface.getByName() bug
Date Mon, 27 Nov 2006 15:31:06 GMT
spark shen wrote:
> Hi All:
> I found a bug of NetworkInterface.getByName() on harmony;It can be
> revealed by the following Test case:
>
> import java.net.NetworkInterface;
> import java.net.SocketException;
>
> public class HelloSpark {
>
> public static void main(String[] args) throws SocketException {
> System.out.println(NetworkInterface.getByName("eth0"));
> }
> }
> ================================================================
> When executed against harmony, this method will return null on my
> machine. And I do have eth0 running. After some investigation, I found
> harmony retrieved wrong name for NetworkInterface.
>
> import java.net.NetworkInterface;
> import java.net.SocketException;
> import java.util.Enumeration;
>
> public class HelloSpark {
>
> public static void main(String[] args) throws SocketException {
> //TODO not yet implemented
> Enumeration<NetworkInterface> nif = NetworkInterface.getNetworkInterfaces();
> while(nif.hasMoreElements()) {
> System.out.println(nif.nextElement());
> }
> }
>
> }
>
> On HY:
> [{655771A5-B1CC-4DFA-BDC4-6822587311EE}][本地连接 2][/9.181.106.82]
> [MS TCP Loopback interface][MS TCP Loopback interface][/127.0.0.1]
>
> On RI:
> name:lo (MS TCP Loopback interface) index: 1 addresses:
> /127.0.0.1;
>
> name:eth0 (Intel(R) PRO/1000 MT Network Connection - ????ü??????ò?????)
> index: 2 addresses:
> /9.181.106.82;
>
> This demonstrates my point.
> ========================================================================
> And then, I found the cause:
> hysock_get_network_interfaces(portlib\src\main\native\port\windows\hysock.c)
> was called to retrieve NetworkInterface related information. This
> function is not properly implemented.
> ========================================================================
> And, at last(Thank you for your patience reading this long :-) ). The
> problem is, modification into this method takes no effects. Would any
> one help me with that? This method is within portlib
>   
I did a basic test to modify the method hysock_get_network_interfaces
you mentioned in following steps, it worked for me:
1. add a printf("hello world\n") to ln 4083 of hysock.c;
2. run ant build-native at classlib/trunk
3. run the test you provided again, it printed out like below, which I
guess shows my modifications on portlib took effect.

null
hello world

Anything I missed?
> Best regards
>
>
>
>
>   


-- 
Paulex Yang
China Software Development Lab
IBM



Mime
View raw message