how to check my ip address ?

Discussion in 'Java' started by vertigo, May 2, 2004.

  1. vertigo

    vertigo Guest

    Hello
    How can i check my IP address ?
    i tried:
    ServerSocket myserversocket= new ServerSocket(0);
    myserversocket.getInetAddress().getAllByName("localhost")
    but it receives only 127.0.0.1,
    and i have two network cards....

    Could anybody help?

    Thanx
    Michal
    vertigo, May 2, 2004
    #1
    1. Advertising

  2. vertigo

    Roedy Green Guest

    Roedy Green, May 2, 2004
    #2
    1. Advertising

  3. vertigo

    Rob Shepherd Guest

    vertigo wrote:
    > Hello
    > How can i check my IP address ?
    > i tried:
    > ServerSocket myserversocket= new ServerSocket(0);
    > myserversocket.getInetAddress().getAllByName("localhost")
    > but it receives only 127.0.0.1,
    > and i have two network cards....
    >
    > Could anybody help?
    >
    > Thanx
    > Michal
    >


    I have a half finished piece of GPLd code to do exactly this.

    http://www.informatics.bangor.ac.uk/~ r o b s h e p/NetworkInterfaceChooser.java

    (remove the spaces from the URL - antispam)

    At present the main() prints to screen all available network interfaces, addresses and
    other bits of info.

    The select() method does a bruteforce First come selection.

    I will, at some point, make a GUI selection thing for pointclick whatever

    The code is part of a GPLd project.

    email me at for offlist chit chat
    Rob Shepherd, May 2, 2004
    #3
  4. vertigo <> wrote in message news:<c72plf$bbo$>...
    > Hello
    > How can i check my IP address ?
    > i tried:
    > ServerSocket myserversocket= new ServerSocket(0);
    > myserversocket.getInetAddress().getAllByName("localhost")
    > but it receives only 127.0.0.1,
    > and i have two network cards....
    >
    > Could anybody help?
    >
    > Thanx
    > Michal


    The www.countrycheck.com home page shows you the IP address you are
    from along with City, State and ISP.
    CountryCheck.com, May 11, 2004
    #4
  5. On Sun, 02 May 2004 14:30:22 +0200, vertigo wrote:
    > How can i check my IP address ?
    > i tried:
    > ServerSocket myserversocket= new ServerSocket(0);
    > myserversocket.getInetAddress().getAllByName("localhost")
    > but it receives only 127.0.0.1,
    > and i have two network cards....


    Note that getAllByName() is a static method, and doesn't tell you
    anything about the address returned by
    myserversocket.getInetAddress().

    You could have just as well written:

    InetAddress.getAllByName("localhost");

    which I *expect* to return 127.0.0.1.

    Have a look at java.io.NetworkInterface instead:
    http://java.sun.com/j2se/1.4.2/docs/api/java/net/NetworkInterface.html

    Note too that "ifconfig -a" or "ipconfig /a" will tell you all of your
    IP addresses, if you don't need to do this programmatically.

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, May 11, 2004
    #5
  6. Also not that just because YOU think you're IP is X, doesn't
    mean that the rest of the world agrees with you (because of
    downline proxies).


    Mike

    vertigo <> wrote in message news:<c72plf$bbo$>...
    > Hello
    > How can i check my IP address ?
    > i tried:
    > ServerSocket myserversocket= new ServerSocket(0);
    > myserversocket.getInetAddress().getAllByName("localhost")
    > but it receives only 127.0.0.1,
    > and i have two network cards....
    >
    > Could anybody help?
    >
    > Thanx
    > Michal
    Michael Scovetta, May 11, 2004
    #6
  7. vertigo

    Roedy Green Guest

    Roedy Green, May 11, 2004
    #7
  8. vertigo

    Roedy Green Guest

    On 11 May 2004 11:44:12 -0700,
    (Michael Scovetta) wrote or quoted :

    >Also not that just because YOU think you're IP is X, doesn't
    >mean that the rest of the world agrees with you (because of
    >downline proxies).


    I use the term "face ip" for the IP the rest of the world thinks you
    are.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, May 11, 2004
    #8
  9. vertigo

    brian Guest

    vertigo <> wrote in message news:<c72plf$bbo$>...
    > How can i check my IP address ?

    Hi, why would you want to know it? You should assume that your program
    might be run on a computer which is not directly connected to the
    internet (dial-up). In that case there is no way to find out your IP
    but contacting a server on the internet and have it tell you.
    If you are writing the server, too, it's socket will have all the
    information which you can easily get and send back to the connecting
    client.
    This won't work of course if the client and the server run on the same
    machine. In that case a local IP will be returned.

    I hope that shed some light.

    regards
    brian
    brian, May 12, 2004
    #9
  10. Hi,

    >The www.countrycheck.com home page shows you the IP address you are
    >from along with City, State and ISP.


    forget that page! It tells me, I am from SANTA CRUZ DE TENERIFE on the
    Canary islands. Unfortunately I'm not, I'm in Hamburg, Germany
    Dirk Michaelsen, May 12, 2004
    #10
  11. vertigo

    Roedy Green Guest

    On Wed, 12 May 2004 08:00:36 +0200, Dirk Michaelsen
    <dirk.michaelsen@NO_SPAMedeka.de> wrote or quoted :

    >forget that page! It tells me, I am from SANTA CRUZ DE TENERIFE on the
    >Canary islands. Unfortunately I'm not, I'm in Hamburg, Germany


    What it is really telling you in the mailing address of your ISP.

    What country am I in? That is not a question that baffles me,
    especially if I have signed up with an ISP there.

    I guess they are just showing off their library.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, May 12, 2004
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. avnrao
    Replies:
    1
    Views:
    7,222
    avnrao
    May 4, 2004
  2. Patrice
    Replies:
    0
    Views:
    883
    Patrice
    May 4, 2004
  3. Raterus
    Replies:
    0
    Views:
    435
    Raterus
    Jun 2, 2004
  4. Alex Stevens
    Replies:
    0
    Views:
    778
    Alex Stevens
    Aug 10, 2004
  5. =?Utf-8?B?QW5nZWw=?=

    Pass a Web Address and return a File System Address

    =?Utf-8?B?QW5nZWw=?=, Sep 20, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    535
    =?Utf-8?B?U3RldmUgQy4gT3Jy?=
    Sep 21, 2005
Loading...

Share This Page