Link to home
Start Free TrialLog in
Avatar of anuj_roy
anuj_roy

asked on

intenet connectivity?

i want to programatically check whether i am connected or not using JAVA?can somebody give a sample code for that?
ASKER CERTIFIED SOLUTION
Avatar of Ovi
Ovi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mick Barry
Not sure if there's a definitive way to check.
pinging as ovi suggested is probably the best solution, although if the machine you ping is down, or the net is slow (causing timeout) then the ping will fail making it appear that you are not connected when in fact you are.
Yes.
Can you explain. How is apps is.

Shyam
Avatar of msterjev
msterjev

boolean con=false;
try
{
     Socket s=new Socket("www.google.com",80);
     con=true;
     s.close();
}
catch(Exception e)
{
     con=false;
}

if(con)
{
   ................
}
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: Ovi
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange