How to getCanonicalHostName() to a given string?

Max Wang Weijun.Wang at Sun.COM
Wed Nov 25 02:42:53 PST 2009


Hi All

I want to write a test running on a single machine. One requirement is  
that both "a" and "b" should be resolved to "127.0.0.1", but their  
getCanonicalHostName() returns "a.one.com" and "b.another.com"  
separately, so that FQDN name lookup for multiple vhosts is possible.

Maybe (?) the OS can be configured to do this, but I want Java codes  
that runs anywhere without changing the system.

Tried looking at user-defined NameService, but seems getHostAddr(ip)  
forgets the original hostname.

Thanks
Max




More information about the net-dev mailing list