Nishit Sharma wrote:
I want to use the 2nd approach as it doesn't depend upon any websites to check for internet connection. So, can anybody tell me how to do it.
Nishit Sharma wrote:you can see the code and the output, here en0 represents ethernet. Ethernet represents both LAN and internet. Now, how to distinguish whether pc is connected to LAN or Internet
how to distinguish whether pc is connected to LAN or Internet
Nishit Sharma wrote:Jeff, i mean to say that sometimes it happens that our pc is on the network, we have access to our company's LAN but at the same time we cannot access internet may be due to some proxy settings. So, my question was in this case how can i come to know whether my pc can access internet using a java program.
Nishit Sharma wrote:
1) You can try connecting to sites such as : google.com, Facebook.com, yahoo.com etc, if you are able to connect to any of these sites that means your pc is connected to internet.
2) You can use java.net.NetworkInterface to find out various network interfaces that are connected.
I want to use the 2nd approach as it doesn't depend upon any websites to check for internet connection. So, can anybody tell me how to do it.
That is a really big piece of pie for such a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|