I need to find the currently active TCP/IP address (dotted Quad for IPv4) from a Java program.
I don't see how to start finding it. Sure, you can always use localhost, but I want to actual assigned address, from the DHCP server. From that, I can query the DNS resolver and find the name.
Everything I've found starts with either the name or the numbers.
Clearly this can be done, as all of the J2EE/JEE5 containers can provide it, as something has to tell the container what the host is to have at the start of the container's Context
From that, its provided in HttpServletRequet's getRequestURL() function. But in my testing, its always "localhost" and I want the real server name.
Interesting, it returns the localhost numeric values, 127.0.0.1, but also returns the host's name. Not the fully qualified name.
So on my machine named "tools" it returns tools. If it returned tools.pfarrell.com, then I could do a DNS lookup to get the number.
It's probably in the network settings. I'm using Windows XP machine connected to a Windows domain at work and a Windows XP machine that is part of a workgroup at home.