• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Remote machine IP

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 15484
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 141
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic