This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Remote machine IP  RSS feed

 
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  
 
Saloon Keeper
Posts: 9218
177
  • 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
 
Saloon Keeper
Posts: 4744
117
  • 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.
 
Author
Ranch Hand
Posts: 96
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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!