views:

139

answers:

1

Hi,

i want to check if an Webserver on on local lan ip is reachable. I checked Apple's Rechability Sample, but this sample says all local lan ip's are reachable.

Any Ideas how to check this?

Thank's

A: 

I made an workaround for this:

- (BOOL *) getOnlineState {
    BOOL *onlineState;
    NSURL *serverURL = [NSURL URLWithString:@"http://192.168.0.10:80/index.html"];
    NSURLRequest *request = [NSURLRequest requestWithURL:serverURL];
    NSURLResponse *response;
    NSError *error;
    NSData *receivedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    if (receivedData == nil) 
        onlineState = (BOOL *)NO;
    else
        onlineState = (BOOL *)YES;
    return onlineState;
}
x2on