• Post Reply Bookmark Topic Watch Topic
  • New Topic

Remote machine IP  RSS feed

 
Prabhash Mishra
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
    I am calling application which is on remote machine.I want to retrieve IP of remote machine in my java application.Can anyone tell me how i will be able to retrieve IP of remote machine.

Thanks,
Prabhash  
 
Stephan van Hulst
Saloon Keeper
Posts: 7991
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you have established a socket connection with the remote machine, you can just call Socket.getInetAddress().

How are you connecting with the remote machine?
 
Prabhash Mishra
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
    Actually some other application is accessing my application through entering URL of my application in browser.I want to know IP of that machine who is accessing my application.

Thanks,
Prabhash
 
Tim Moores
Saloon Keeper
Posts: 4034
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So there is a servlet running in your app, or something like it? HttpServletRequest has the getRemoteAddr method that tells you where the request originated.
 
Marco Behler
Author
Ranch Hand
Posts: 93
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, if you are talking about a web application, you always have to make sure that the web server, like Apache or Nginx, which often sits in front of your Java app....actually FORWARDS that IP to you. Hint: X-Real-IP
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!