How about adding an identifier called $isconn? This would return $true if you are connected to the internet, and $false if you are not.