What is the best and fastest way to check network status ?

Hi,

I would like to check network status before I send any query to server, but after I studied and tested SDK, I found only two possible way can be used,

First method is using socket.connect() as following:

  local client = socket.connect(“www.google.com”,  80)

connection status can be confirmed by checking if (client ~= nil) then …

Second method is using network.request() as following:

  network.request( “http://www.google.com”, “GET”, networkListener )

connection status can be confirmed from networkListener by checking event.isError

First method is fast but system will hang a while to wait timeout  (all the button is locked) if 3G signal is unstable. The second method is slower than First method but more accuracy.

Is there any better and faster way to detect network status ?

By the way, what I mean for “3G signal is unstable” is mobile phone had 3G indicator shown but with very low signal strength.

Thanks

Hi @farmer,

Please see the example on this page. It should provide a good foundation that you can work from, but as with all things network-related, there is no “silver arrow” that can be expected to work in every case on every device under all user/device configurations.

http://docs.coronalabs.com/api/library/network/setStatusListener.html

Brent

Hi,

Does network.canDetectNetworkStatusChanges suppport Android platform ?

I tested network.canDetectNetworkStatusChanges in Android platform but got false result.

What is the best and fastest way to check network status in Android and iOS ?

I quite like this method shared recently by fellow forum member @gazjm. Hope this helps. 

http://forums.coronalabs.com/topic/45187-method-for-detecting-if-you-have-a-good-internet-connection/?hl=checknet.php

Thanks,

So far this is really the best way to detect network  connection status. I am still looking forward corona SDK can provide more speedy API to detect network connection status.

Best Regards,

Hi @farmer,

Please see the example on this page. It should provide a good foundation that you can work from, but as with all things network-related, there is no “silver arrow” that can be expected to work in every case on every device under all user/device configurations.

http://docs.coronalabs.com/api/library/network/setStatusListener.html

Brent

Hi,

Does network.canDetectNetworkStatusChanges suppport Android platform ?

I tested network.canDetectNetworkStatusChanges in Android platform but got false result.

What is the best and fastest way to check network status in Android and iOS ?

I quite like this method shared recently by fellow forum member @gazjm. Hope this helps. 

http://forums.coronalabs.com/topic/45187-method-for-detecting-if-you-have-a-good-internet-connection/?hl=checknet.php

Thanks,

So far this is really the best way to detect network  connection status. I am still looking forward corona SDK can provide more speedy API to detect network connection status.

Best Regards,