• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Determine if PC is connected to internet

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to for my Swing application to determine the internet connecttion status of the host PC when it starts. How does one do this?
Pseudo-code:
if(isConnected == true)
{
execute query to download data into JTables
}
else{
show not connected pop-up;
System.exit(1);
}
Thanks for any help,
Pete
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Peter,
what you can do, is the following.
Also in pseudo-code
try {
execute code
} catch (NotConnectedException e) {
show pop-up;
System.exit(1);
}
Its quite a dirty trick, but it works ;-)
Greetings,
Marcel
 
Peter Simard
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marcel,
Here's what I've decided to do.
inside my main method I connect to the US gov time server, If I get an aswer then i'm connected, if no answer I'm not connected.
Another hack/dirty trick, but it should suffice for the time being...

Or i could just connect to the database in question...using the same logic. I need coffee!
[ October 11, 2002: Message edited by: Peter Simard ]
[ October 11, 2002: Message edited by: Peter Simard ]
[ October 11, 2002: Message edited by: Peter Simard ]
 
BWA HA HA HA HA HA HA! Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic