Is it possible to check internet conneciton for WWW class downloading ?

Hi,

I'm trying to download something through WWW class.When I'm connected to internet, there is no problem. But when I'm not connected , In editor, it returns WWW.error , but in standalone it remains at (yield www).

Is there any way to check internet connection ?

I'm using unity pro 2.6.1.

WWW www;
void Start()
{
www = new WWW(“www.google.com”);
StartCoroutine(checkConniction());
}

IEnumerator  checkConniction()
{
	yield return www;
	
	if(www.error != null)
	{
		print("faild to connect to internet, trying after 2 seconds.");
	  yield return new WaitForSeconds(2);// trying again after 2 sec
	  StartCoroutine(checkConniction());
	}else
	{
		print("connected to internet");
		// do somthing, play sound effect for example
		yield return new WaitForSeconds(5);// recheck if the internet still exists after 5 sec
	 	StartCoroutine(checkConniction());
		
	}

}

Cheeers

http://unity3d.com/support/documentation/ScriptReference/Ping.html

You could use this, and if isDone returns false, it's not connected, so then you can display a message.

Might work, not to sure, something to check out none-the-less.

Since I only want to check internet connection to reach some server, I use this:

	static public bool IsConnectionToServerOk () {
		WebRequest request = HttpWebRequest.Create(HomeGlobal.bundleURL);
		request.Method = "HEAD";
		WebResponse resp = null;
		try {
			resp = request.GetResponse();
		} catch {
			resp = null;
		}
		return resp != null;
	}

But this is too simplistic and very problematic if you can’t afford to keep your whole application on hold for the response. Using async calls as in here, is much better.