0

Possible Duplicate:
SCNetworkReachabilityGetFlags returns 0 even when wireless available

We are using SCNetworkReachabilityGetFlags to determine if internet connectivity is available. On certain phones it does occasionally provide wrong information, saying that some host or ip address can not be reached. When ignoring the flags and launching a request anyway, everything works fine.

This answer suggests that switching airplane mode on and off again releases a cache SCNetworkReachabilityGetFlags might be using: SCNetworkReachabilityGetFlags returns 0 even when wireless available

Obviously this is not really an option from a usability perspective. Has any one encountered the same problem? Are there alternatives for checking the reachability?

Community
  • 1
  • 1
Arno Fiva
  • 1,459
  • 1
  • 13
  • 17

2 Answers2

0

My be Resetting the network settings my work.

Ramakrishna Guttha
  • 762
  • 1
  • 12
  • 24
  • 1
    It seems to be a general problem, not only on this specific phone. The user shouldn't have to change anything in the settings if connectivity is actually available. – Arno Fiva Nov 14 '11 at 11:24
0

You could also use a nice method of NSURL,

- (BOOL)checkResourceIsReachableAndReturnError:(NSError **)error

NSURL Developer documentation

This of course would not be very useful if you want to receive a notification when the network goes offline ( or online for that matter ) like you can do with System Configuration.

In my IM application for tha Mac I have a watchdog ( 20 second timer ) because SystemConfiguration was not always reliable enough for me.

Antwan van Houdt
  • 6,989
  • 1
  • 29
  • 52
  • So in the watchdog you use the NSURL method? And you can confirm having the same problems with SCNetworkReachabilityGetFlags? We experience it even after restarting the app. – Arno Fiva Nov 14 '11 at 11:23
  • No my library takes care of determining whether the network is reachable or not, not using NSURL in that case. -- Also I just tried this myself.. and it is useless for you as it seems that this is only for file resources and not remote recources. You could also try writing a class that is able to send a packet through a socket, if that is sucessfull you know the network is reachable, in the SC documentatino they basically say they do the same thing.. – Antwan van Houdt Nov 14 '11 at 11:29
  • From the linked documentation: `checkResourceIsReachableAndReturnError:` Returns whether the resource pointed to by a **file** URL can be reached. So that method is not an option. – Christian Beer Jun 25 '13 at 06:23