Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Java: Finding out my own IP?

  • 20-12-2007 02: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, Registered Users 2 Posts: 12,036 ✭✭✭✭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, Registered Users 2 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
Advertisement