see clearly i am able to get the ip address of remote system i.e., 172.20.129.39 but the name is same as local host. Here i think will always return the name of local host. but i need the name of remote system. please suggest me
1) Your code explicitly calls "getLocalHost()" - is it really surprising that you're getting the name of localhost? Note that that is a static method of InetAddress; what do the javadocs say it does?
2) Be aware that many (or most) machines will have not a name that can be looked up in this way. What you need to do is to perform a DNS lookup of that IP address's A record. The DNSJava library can do that pretty easily.
output ip address::172.20.129.39
according to API request.getRemoteHost() should return qualified name of remote system, but i am still getting IP address for this statement. Can't we get the name of remote system.
posted 5 years ago
What do the javadocs of the getRemoteHost method have to say about that? They certainly don't say that it will always return a machine name.
But to me it doesn't look like 172.20.129.39 has a DNS A record, at least not a public one. Does it have a private A record in your network's DNS server? Most machines won't have that, though. And InetAddress knows nothing about remote machine names that aren't part of DNS, just in case that's what you were hoping for.