This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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: 8907
167
  • 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: 4479
112
  • 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
 
I'm still in control here. LOOK at this tiny ad!
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!