How can I check internet conection?

F

Flamadin

Hello, I need to check internet conection. Actualy I use:

InetAddress[] all =
InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());

Whith this code, when a computer is conected to a lan but isn't conected to
internet, I only get the private address, and when it uses a dial-up
conection and I try to check internet conection again (the program is still
running) this function returns the same (only private address). How can I
refresh IP address?

Thanks

Patrick
 
S

Sam

Flamadin said:
Hello, I need to check internet conection. Actualy I use:

InetAddress[] all =
InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());

Whith this code, when a computer is conected to a lan but isn't conected to
internet, I only get the private address, and when it uses a dial-up
conection and I try to check internet conection again (the program is still
running) this function returns the same (only private address). How can I
refresh IP address?

Thanks

Patrick

Patrick,

I think what's happening is that you're still connected to the lan, by
means of a nic card, which is associated with an ip address (type
ipconfig to see this). This address doesn't change despite the fact
that you are now connecting to the internet via a modem.

I'm pretty sure an ISP uses NAT to translate between thier public
(static) ip and the one that's being used for communication with your
system in the case of modem. It probably dynamically assigns an ip
address each time you dial in. Otoh, the IP address assigned to your
home varies every few days or something when you have a permanent
connection with your isp (such as cable). Note that if you have a lan
in your home, your lan address doesn't change - I'm guessing that your
lan router does a similar conversion between your dynamically assigned
ip address and your lan's static addresses.

Which still doesn't answer the question of what is the dynamic ip
address assigned to your modem? That I don't know. One thing you could
do is install a packet monitor, and then just look at the ip address -
but I don't know monitors works on modems.

Regards,
Mark
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top