Skip to content

Instantly share code, notes, and snippets.

@dreamcat4
Created April 26, 2009 13:00
Show Gist options
  • Save dreamcat4/102033 to your computer and use it in GitHub Desktop.
Save dreamcat4/102033 to your computer and use it in GitHub Desktop.
Cocoa snippets
// 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