Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > LinkLocal Address ( InetAddress.getByName throws UnknownHostException )

Reply
Thread Tools

LinkLocal Address ( InetAddress.getByName throws UnknownHostException )

 
 
saggar
Guest
Posts: n/a
 
      06-15-2011
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%et h0");
}
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(Inet6Addr ess.java:
35
at java.net.Inet6Address.initif(Inet6Address.java:321 )
at java.net.Inet6Address.initstr(Inet6Address.java:30 6)
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:95 9)

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

-Sunil
 
Reply With Quote
 
 
 
 
Lewis Bloch
Guest
Posts: n/a
 
      06-17-2011
On Jun 14, 11:15*pm, saggar <(E-Mail Removed)> wrote:
> 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%et h0");
> * * *}
> * * *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(Inet6Addr ess.java:
> 35
> * * * * at java.net.Inet6Address.initif(Inet6Address.java:321 )
> * * * * at java.net.Inet6Address.initstr(Inet6Address.java:30 6)
> * * * * 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:95 9)
>
> 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.

--
Lew
 
Reply With Quote
 
 
 
 
lewbloch
Guest
Posts: n/a
 
      06-17-2011
On Jun 17, 6:27*am, Lewis Bloch <(E-Mail Removed)> wrote:
> On Jun 14, 11:15*pm, saggar <(E-Mail Removed)> wrote:
>
>
>
>
>
>
>
>
>
> > 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%et h0");
> > * * *}
> > * * *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(Inet6Addr ess.java:
> > 35
> > * * * * at java.net.Inet6Address.initif(Inet6Address.java:321 )
> > * * * * at java.net.Inet6Address.initstr(Inet6Address.java:30 6)
> > * * * * 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:95 9)

>
> > 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.
>


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.

--
Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Webstart not working offline (NoRouteToHostException/UnknownHostException) Mathias Lin Java 1 09-15-2010 07:22 AM
Unhandled exception type UnknownHostException Linus Java 1 02-25-2005 11:21 AM
UnknownHostException on Japanese Windows XP - Please Help!!! Dave Raskin Java 0 04-26-2004 07:17 PM
UnknownHostException --- Does JVM cache results from DNS queries? noone Java 3 11-11-2003 12:37 AM
XmlValidatingReader throws exception for SAOP-ENV:encodingStyle attribute Himmat Dhange ASP .Net 0 08-26-2003 08:28 PM



Advertisments