简体   繁体   中英

Rechability of Local LAN Ip on iPhone/iPad?

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

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM