开发者

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜