I need to determine if Internet Connection is available or not. I don’t care how it is connected (WI-FI, Lan,etc..) . I need to determine, is Internet Connection available at all .
P.S. I found a way to check WI-FI connection. But I don’t care how it is connected (I need to check all the ways that can be connected to Internet).
Something like (isConnected)
Take a look at the
SCNetworkReachabilityreference. This is a C API, so it’s not as easy to use as a single method call, but it does a great job of notifying your app when a particular address becomes reachable or unreachable over the network.The broad outline is you’ll create an object with
SCNetworkReachabilityCreateWithAddressorSCNetworkReachabilityCreateWithName, and then add it to the run loop withSCNetworkReachabilityScheduleWithRunLoop. When the reachability is determined and when it changes, the callback function you supply will be called. You can use that to update the state of your application.Apple supplies an example app that shows how to use this (although it’s designed for iOS, not Mac OS X)