how to check my ip address ?

V

vertigo

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
 
R

Rob Shepherd

vertigo said:
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 (e-mail address removed) for offlist chit chat
 
C

CountryCheck.com

vertigo said:
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.
 
G

Gordon Beaton

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
 
M

Michael Scovetta

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
 
R

Roedy Green

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.
 
B

brian

vertigo said:
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
 
R

Roedy Green

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top