关于ios 网络连接的问题

xlfrank
  • 47

我在做一个聊天app,

从wifi切换到蜂窝数据,网络正常可以访问到服务器,

从蜂窝切换到wifi的时候也正常可以访问到服务器,

但当使用蜂窝数据并启用3G的话,会出现长时间连不到服务器,最终也能连接上(我想切换后短时间内就能连接上, 因为时间过长给用户的感觉不好。)

下面是输出网络的切换3G后的网络状态,

SCNetworkReachabilityFlags reachabilityFlags = 0;

BOOL reachbilityState = SCNetworkReachabilityGetFlags(reachability, &reachabilityFlags);

    NSLog(@"reachbilityState %i",reachbilityState);

    NSLog(@"reachabilityFlags  %i",reachabilityFlags);

    NSLog(@"kSCNetworkReachabilityFlagsReachable %i",kSCNetworkReachabilityFlagsReachable);

    NSLog(@"kSCNetworkReachabilityFlagsTransientConnection %i",kSCNetworkReachabilityFlagsTransientConnection);

    NSLog(@"kSCNetworkReachabilityFlagsConnectionRequired %i",kSCNetworkReachabilityFlagsConnectionRequired);

    NSLog(@"kSCNetworkReachabilityFlagsConnectionOnTraffic %i",kSCNetworkReachabilityFlagsConnectionOnTraffic);

    NSLog(@"kSCNetworkReachabilityFlagsInterventionRequired %i",kSCNetworkReachabilityFlagsInterventionRequired);

    NSLog(@"kSCNetworkReachabilityFlagsConnectionOnDemand %i",kSCNetworkReachabilityFlagsConnectionOnDemand);

    NSLog(@"kSCNetworkReachabilityFlagsIsLocalAddress %i",kSCNetworkReachabilityFlagsIsLocalAddress);

    NSLog(@"kSCNetworkReachabilityFlagsIsDirect %i",kSCNetworkReachabilityFlagsIsDirect);

    NSLog(@"kSCNetworkReachabilityFlagsIsWWAN %i",kSCNetworkReachabilityFlagsIsWWAN);

reachbilityState 1

2013-04-25 17:15:04.047 reachabilityFlags 262147

2013-04-25 17:15:04.048 kSCNetworkReachabilityFlagsReachable 2

2013-04-25 17:15:04.049 kSCNetworkReachabilityFlagsTransientConnection 1

2013-04-25 17:15:04.051 kSCNetworkReachabilityFlagsConnectionRequired 4

2013-04-25 17:15:04.052 kSCNetworkReachabilityFlagsConnectionOnTraffic 8

2013-04-25 17:15:04.057 kSCNetworkReachabilityFlagsInterventionRequired 16

2013-04-25 17:15:04.058 kSCNetworkReachabilityFlagsConnectionOnDemand 32

2013-04-25 17:15:04.059 kSCNetworkReachabilityFlagsIsLocalAddress 65536

2013-04-25 17:15:04.061 kSCNetworkReachabilityFlagsIsDirect 131072

2013-04-25 17:15:04.062 kSCNetworkReachabilityFlagsIsWWAN 262144

请问 状态262147 是什么状态,我该怎么做才能让app更快的连接上服务器。 谢谢

回复
阅读 5.2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏