In my App, I wanted to check if there any type of existing network available in current OS X system. Ethernet or Internet or Wifi or 3G-card or any other type of network communication.
How can I achieve that?
Thank you!
https://stackoverflow.com/questions/5662298...
Thank bdash and cody! I do my homework and found another answer above. But that is for iPhone, I make some modification below.
- (BOOL)isAnyNetworkExist
{
    struct sockaddr_in nullAddress;
    bzero(&nullAddress, sizeof(nullAddress));
    nullAddress.sin_len = sizeof(nullAddress);
    nullAddress.sin_family = AF_INET;
    SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*) &nullAddress);
    SCNetworkReachabilityFlags flags;
    SCNetworkReachabilityGetFlags(ref, &flags);
    CFRelease(ref);     /* !!! */
    AMCDebug(@"Flag: 0x%08X", flags);
    if (0 != (flags & kSCNetworkFlagsIsLocalAddress))
    {
        return YES;
    }
    else
    {
        return NO;
    }
}
I check the "kSCNetworkFlagsIsLocalAddress" ONLY, but I am not sure if this OK.
I tried the flag when I remove all network connection and it returned 0x07.
 
     
    