Skip to main content
Inspiring
September 3, 2012
Answered

check if online

  • September 3, 2012
  • 1 reply
  • 1052 views

Hi,

I'm not as close to network, networkprotocolls and co.

question:

Will this be a safe way to check if a user is 'online' (connected to the internet by wlan or lan or ...)

var myConnection = new Socket();

if(myConnection.open ("www.google.de:80")) {myConnection.close();}else{alert('Not connected.')}

This topic has been closed for replies.
Correct answer benjaminmueller_burda

sure .. connect to the dropbox URL http://www.dropbox.com oder their API https://api.dropbox.com/ instead of connecting to google

1 reply

benjaminmueller_burda
Participating Frequently
September 3, 2012

Hi,

  • your code definitly works
  • being able to connect to "google.de" is not a save definition of being "online".  Firewalls, Proxies etc can ruin your day. 
  • rather check the connection to the online service you want to connect to (if that is google, forget what I said) .. 

Regards

b.

-hans-Author
Inspiring
September 3, 2012

hi,

I want to get sure that the dropbox can work ...is there a concrete way to check for connectivity of the dropbox¿

benjaminmueller_burda
benjaminmueller_burdaCorrect answer
Participating Frequently
September 3, 2012

sure .. connect to the dropbox URL http://www.dropbox.com oder their API https://api.dropbox.com/ instead of connecting to google