Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java: Finding out my own IP?

Options
  • 20-12-2007 2:33am
    #1
    Closed Accounts Posts: 12,382 ✭✭✭✭


    Hello

    Does anyone know how I find out my own IP in Java?

    Is it InetAddress.getAddress ?

    Basically I would like to find out my own IP address and then package it as a string.

    Any help appreciated.

    Thanks


Comments

  • Registered Users Posts: 11,977 ✭✭✭✭Giblet


    getLocalHost

    You probably aren't going to be able to get your address. Try reading http://whatismyip.org/ it's just a blank site with only your ip listed, could read that in java. (Unless of course you have your external ip mapped to your computer, then getLocalHost() should work.)


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes




  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    Generally speaking if you're looking to get your external IP address you have to scrape a site like whatismyip.com, or you need to query a UPNP enabled router. That might be of some use to ya.


Advertisement