Check Internet Connection

Hi

I am working in a game (android and iPhone) which connect to internet to get some data, but I have not find any method to know if the internet connection has been lost or has been restored, is there any way to know that?

Thank you very much

I have implemented this requesting a http page with CURL. Not sure if it’s the best way to do it, but you are 99 sure about the result (1 is that the website is down…)

On iOS you should use the sample code Reachabilty from Apple. The OBJ-C callbacks should be forwarded to the C++ code then. Use CCNotificationCenter for this.

The Reachability stuff was already done from someone at the forum here. Search for network I guess

Thanks for your answers!

Jesús, I will implement it with CURL if no other way is found, but using CURL, the application has to check by itself the connection… what I wanted to mean was if there is some handle or delegate which indicates if the internet connection is lost or is restored.

Herman, I think your idea is the correct one, but it is only for iOS, is not it? Do you know something useful for both environments?

Hermans idea is better. I tried to implement that but I think it was very complex. But thats because I didn’t know about the CCNotificationCenter class :)
Anyway, to check the internet connection on Android in its native code sucks , I have had a lot of problems with native projects, so the cURL option is not bad… I do a httprequest to a dummy page that contains some kind of hello world text, if the request was successful I know that there is internet connection.
But in the ideal world, I would use Herman solution :
)