Revision: 10406
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 26, 2008 02:53 by warhero
Initial Code
#import "AppController.h" #import <CoreFoundation/CoreFoundation.h> #import <SystemConfiguration/SCNetworkReachability.h> @implementation AppController - (IBAction)checkConnection:(id)sender { NSAlert *alert = [[[NSAlert alloc] init] autorelease]; [alert setAlertStyle:NSInformationalAlertStyle]; [alert addButtonWithTitle:@"Ok"]; [alert setInformativeText:@"Connection Test"]; const char *hostname = "google.com"; SCNetworkConnectionFlags flags; if(SCNetworkCheckReachabilityByName(hostname, &flags)) { if(kSCNetworkFlagsReachable & flags && !(kSCNetworkFlagsConnectionRequired & flags)) { [alert setMessageText:@"You are connected!"]; [alert runModal]; return; } } [alert setMessageText:@"You are not connected!"]; [alert runModal]; } @end
Initial URL
Initial Description
Initial Title
Check Network Connection with SCNetworkCheckReachabilityByName
Initial Tags
Initial Language
Objective C