Created
April 26, 2017 13:43
-
-
Save slambert/23c44d0f2136766de3b8d277980abb20 to your computer and use it in GitHub Desktop.
This uses processing to see if you're currently connected to the internet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Very expensive network connection checker | |
Steve Lambert 2017-04-26 | |
*/ | |
void setup() { | |
size(250,250); | |
smooth(); | |
} // end setup | |
void draw() { | |
if (frameCount % 100 == 0){ // every 100th frame do this... | |
// pull lines of text from google's webpage into a string: | |
String[] lines = loadStrings("http://google.com"); | |
// Now, check to see if anything comes back. If nothing comes | |
// back, it returns "null". If we don't check for that, it | |
// will cause an error and the program will crash. So we test | |
// for null, which will tell us if we're connected at all. | |
if (lines == null){ | |
println("congratulations, you're off the internet"); | |
} else { | |
//println("there are " + lines.length + " lines"); | |
println("Hi, I see you're on the internet"); | |
} | |
} | |
} // end draw | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment