LinkLocal Address ( InetAddress.getByName throws UnknownHostException )

S

saggar

Hi,

I used the following code to create a InetAddress from lilnklocal
address ( returned by getifaddrs function).
try{
InetAddress add =
InetAddress.getByName("fe80::216:3eff:fe38:74e8%eth0");
}
catch(UnknownHostException uhe){
System.out.println("Caught unknownhost exception ");
System.out.println("Message: "+uhe.getMessage());
uhe.printStackTrace();
}


But it fails with the following message.

java.net.UnknownHostException: no scope_id found
at java.net.Inet6Address.deriveNumericScope(Inet6Address.java:
358)
at java.net.Inet6Address.initif(Inet6Address.java:321)
at java.net.Inet6Address.initstr(Inet6Address.java:306)
at java.net.Inet6Address.<init>(Inet6Address.java:232)
at java.net.InetAddress.getAllByName(InetAddress.java:1062)
at java.net.InetAddress.getAllByName(InetAddress.java:1009)
at java.net.InetAddress.getByName(InetAddress.java:959)

What could be the possible reasons for it ? Is it specific to JDK
version ?

-Sunil
 
L

Lewis Bloch

Hi,

I used the following code to create a InetAddress from lilnklocal
address ( returned by getifaddrs function).
   try{
        InetAddress add =
InetAddress.getByName("fe80::216:3eff:fe38:74e8%eth0");
     }
     catch(UnknownHostException uhe){
        System.out.println("Caught unknownhost exception ");
        System.out.println("Message: "+uhe.getMessage());
        uhe.printStackTrace();
    }

But it fails with the following message.

java.net.UnknownHostException: no scope_id found
        at java.net.Inet6Address.deriveNumericScope(Inet6Address.java:
358)
        at java.net.Inet6Address.initif(Inet6Address.java:321)
        at java.net.Inet6Address.initstr(Inet6Address.java:306)
        at java.net.Inet6Address.<init>(Inet6Address.java:232)
        at java.net.InetAddress.getAllByName(InetAddress.java:1062)
        at java.net.InetAddress.getAllByName(InetAddress.java:1009)
        at java.net.InetAddress.getByName(InetAddress.java:959)

What could be the possible reasons for it ?  Is it specific to JDK
version ?

The error message is quite clear - the DNS does not recognize the host
name. What you passed to the call really doesn't look like a host
name, so that seems unsurprising.
 
L

lewbloch

The error message is quite clear - the DNS does not recognize the host
name.  What you passed to the call really doesn't look like a host
name, so that seems unsurprising.

Oops. I should follow my own advice and check Javadocs first. Sorry.

It doesn't look specific to the JDK - the error says that the scope ID
was not found. The scope ID is "eth0", which implies that that
interface was not available on the target system at run time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top