Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by AliAzin · Jan 05, 2011 at 01:55 PM · wwwdownloadinternet

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.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image zuchochoko · Jul 05, 2011 at 09:31 PM 0
Share

Hi

Hey, I found myself reading your question you said you could download things with the class WWW, look I tell you I'm doing an application in which I have to download files from a page x, but not e able to find me something to help me.

$$anonymous$$y question is if you pudes spend part of your code that makes the file download please only that part I'd appreciate it very much.

avatar image cregox · Nov 06, 2012 at 03:47 PM 0
Share

duplicate: http://answers.unity3d.com/questions/35896/how-can-one-test-if-there-is-any-internet-wi-fi-or.html

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Justin Warner · Jan 05, 2011 at 02:37 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cregox · Jan 22, 2013 at 10:54 AM 0
Share

This should not work for every case, because the HTTP server can block IC$$anonymous$$P (ping) requests.

avatar image
1

Answer by Wajdi-azar · Jan 22, 2013 at 07:44 AM

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ankit Priyarup · Apr 02, 2014 at 10:30 AM 0
Share

Please help, it's not working on my android device

avatar image
0

Answer by cregox · Nov 06, 2012 at 03:53 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Get information from internet for my game 0 Answers

WWW/ yield calls throwing errors on iPad 1 Answer

Downloading files in the Editor 2 Answers

Google Insights 0 Answers

downloading file, saving on android 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges