Skip to content

Instantly share code, notes, and snippets.

@ejknapp
Created December 5, 2009 18:51
Show Gist options
  • Select an option

  • Save ejknapp/249805 to your computer and use it in GitHub Desktop.

Select an option

Save ejknapp/249805 to your computer and use it in GitHub Desktop.
// How to poll the server periodically
- (BOOL)testForFlakServer:(NSString *)hostURL {
NSString *urlString = [NSString stringWithFormat:@"%@/flak", hostURL];
NSLog(@"urlString: %@", urlString);
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSHTTPURLResponse *response = nil;
NSError *error = nil;
[NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
NSInteger statusCode = [response statusCode];
NSLog(@"statusCode: %d", statusCode);
if (statusCode == 200) {
return YES;
} else {
return NO;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment