Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
760 views
in Technique[技术] by (71.8m points)

iphone - SCNetworkReachabilityGetFlags returns 0 even when wireless available

I have an app that uses Apples reachability code. When I tab out of the app, turn on airplane mode, go back into the app, I correctly get a message that says no connection is available. If I go back out turn OFF airplane mode and go back into the app, I STILL get the message that no connection is available. The specific problem code is this:

NetworkStatus status = kNotReachable;
if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
{
    status = [self networkStatusForFlags: flags];
    return status;
}

I get inside the if statement and flags ends up being 0 (kSCNetworkReachabilityFlagsTransientConnection). What does that mean exactly? Has anyone experienced this and does anyone know a work-around or fix? Been playing with it for hours...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have found that this is caused by supplying a hostname with a protocol specifier (such as http://hostname instead of just hostname). Try specifying just the hostname by itself to see if this fixes your problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...