permaculture playing cards*
The moose likes Sockets and Internet Protocols and the fly likes Getting the Client machine name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Getting the Client machine name" Watch "Getting the Client machine name" New topic
Author

Getting the Client machine name

surendar prabu
Ranch Hand

Joined: Jul 24, 2006
Posts: 102
In my application i need to get the name of the client machine that is making the request. I am using the getRemoteHost method. But it is returning the IP Address of the client. is there any way i can resolve the name of the client machine from that or any other method is there to get the client name.

regards,
Surendarprabu


SCJP 1.4
Thomas Mcfarrow
Ranch Hand

Joined: Jul 09, 2001
Posts: 137
you could use nslookup <ip-address>. This is a common command for your OS.
Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
The servlet API indicates that the container is not required to convert the requestor's IP address into a host name (for the sake of speed) ... In that case, getRemoteHost will return the remote IP instead.

If you desire, you can manually intervene to look up the remote host name if the container has decided not to do so. Here's a code snippet that I use:



Fun programming etcetera!
Ajay Singh
Ranch Hand

Joined: Dec 13, 2006
Posts: 182
You can get the name of the client machine if the client is on the public domain or in the same network as the server.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting the Client machine name