• Post Reply Bookmark Topic Watch Topic
  • New Topic

detect conn through java program.

 
gulshan grover
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i check through java program on a personal computer wheather computer is connected to internet or not. can some one tell me about code to be use and java package to be use.
 
Van Glass
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way I can think to do this is to try and establish a connection to a well known port/hostname. If you get a timeout when trying to establish the connection then more than likely they are not connected.
Note: The timeout for a Socket connection is fairly long so you may want to write a class which throws an Exception if it cannot establish a connection within a given period of time (1-2 seconds).

------------------
JScape - Java Network Components www.jscape.com
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!