Joh*_*all 5 iphone posix nsstream cfnetwork ios
在对我的iOS 6应用程序进行了一些更改后(其中没有一个实际上与网络有关),我开始遇到一个奇怪的错误,我的流事件处理程序.这在iOS 5和iOS 6上都会发生,但在iOS 5上更频繁.这个错误每50秒发生一次,我的流事件处理程序遇到了NSStreamEventErrorOccurred.错误信息如下:
Application[6370:707] Error Occured with stream [<__NSCFInputStream: 0xd622ab0>]
Application[6370:707] Stream Status: 7
Application[6370:707] Error Code: 57
Application[6370:707] Error Desc: The operation couldn’t be completed. Socket is not connected
Application[6370:707] Error Reason: Socket is not connected
Application[6370:707] Error Domain: NSPOSIXErrorDomain
Run Code Online (Sandbox Code Playgroud)
发生此错误后,处理程序将遇到一对'连接重置对等'TCP错误,我认为这是由服务器发送RST数据包引起的.是否有任何其他方案可能导致此错误?我的应用程序正在连接到以AP模式广播wifi网络的硬件设备.
以下是我的NSStreamEventHasBytesAvailable活动代码.
case NSStreamEventHasBytesAvailable: {
NSLog(@"Stream has bytes available! Stream is %@", stream);
if (stream == iStream)
{
@try {
uint8_t buf[2048];
unsigned int len = 0;
len = [(NSInputStream *)stream read:buf maxLength:2048];
if(len) {
NSString *incomingData = [[NSString alloc] initWithBytes:(const void *)buf length:len encoding:NSUTF8StringEncoding];
}
} catch (NSException *e) {
NSLog(@"Caught Exception: %@",e);
}
}
break;
}
Run Code Online (Sandbox Code Playgroud)
请根据需要提供信息,谢谢您的时间!
| 归档时间: |
|
| 查看次数: |
1413 次 |
| 最近记录: |