[kaffe] IP address autodetection

Timothy Stack stack at cs.utah.edu
Sun Feb 23 13:48:01 PST 2003

On Sunday, February 23, 2003, at 11:48  AM, Matthew Toseland wrote:

> While trying to get freenet working on Kaffe, I discovered a side
> issue... we use the attached code to detect the local internet IP
> address. Basically, we open a datagram socket to the A-root nameserver
> and call getLocalAddress().

why not just use InetAddress.getLocalHost()?  Or, 
useNetworkInterface.getNetworkInterfaces() and handle the 
NoClassDefFoundError with this method.

>  This returns on Kaffe CVS;

Its probably wrong, but its a very gray area and making dependencies on 
it doesn't seem like a good idea.  The javadoc for getLocalAddress() 
says it returns "the local address to which the socket is bound, or an 
InetAddress representing any local address."  Since the attached 
example didn't do a bind its technically correct to return the any 
address (  Also, connecting a datagram socket discriminates on 
the remote address, not the network interface.  So, again, its very 
dodgy behavior to be relying on.

> -- 
> Matthew Toseland


More information about the kaffe mailing list