开发者

Rechability of Local LAN Ip on iPhone/iPad?

开发者 https://www.devze.com 2022-12-26 01:36 出处:网络
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.

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

精彩评论

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

关注公众号