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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes.
Can you explain. How is apps is.
Shyam
Can you explain. How is apps is.
Shyam
boolean con=false;
try
{
Socket s=new Socket("www.google.com",80);
con=true;
s.close();
}
catch(Exception e)
{
con=false;
}
if(con)
{
................
}
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
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
modulo
Community Support Moderator
Experts Exchange
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.