Created
April 26, 2009 13:00
-
-
Save dreamcat4/102033 to your computer and use it in GitHub Desktop.
Cocoa snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Is hostname reachable ? | |
- (BOOL) isReachable:(NSString *)hostname | |
{ | |
SCNetworkConnectionFlags flags; | |
if (!SCNetworkCheckReachabilityByName([hostname cStringUsingEncoding:NSASCIIStringEncoding], &flags)) | |
return FALSE; | |
// If a connection is required, then it's not reachable | |
if (flags & (kSCNetworkFlagsConnectionRequired | kSCNetworkFlagsConnectionAutomatic | kSCNetworkFlagsInterventionRequired)) | |
return FALSE; | |
return flags > 0; | |
} | |
// Command-line interface | |
pieter/gitx / PBCLIProxy.h | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment