在IOS 7.0中,CFStream套接字发送数据包未完成

时间:2013-09-25 10:15:43

标签: ios objective-c c ios7 cfstream

我使用CFStream Socket向Host发送数据。 第一次发送就是工作。 但是首先,主机的数据总是被分配。 例如:

第一次发送:

Sender:  <11223344 55667788>
Recver:  <11223344 55667788> 

好的,这很好

第二次,第三次......

Sender:  <11223344 55667788>
Recver:  <11>
Recver:  <223344 55667788> 

此症状仅发生在IOS 7.0中。 在6.0,5.0中没有这种症状......

enter code here
CFReadStreamRef inputStream;
CFWriteStreamRef outputStream;
CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)_owner.ip, _owner.port, &inputStream, &outputStream);
NSDictionary *sslSettings = @{(id)kCFStreamSSLValidatesCertificateChain: (id)kCFBooleanFalse};
CFReadStreamSetProperty(inputStream, kCFStreamPropertySocketSecurityLevel, kCFStreamSocketSecurityLevelTLSv1);
CFReadStreamSetProperty(inputStream, kCFStreamPropertySSLSettings, (__bridge CFTypeRef)(sslSettings));
CFWriteStreamSetProperty(outputStream, kCFStreamPropertySocketSecurityLevel, kCFStreamSocketSecurityLevelTLSv1);
CFWriteStreamSetProperty(outputStream, kCFStreamPropertySSLSettings, (__bridge CFTypeRef)(sslSettings));
_inputStream = (__bridge_transfer NSInputStream *)inputStream;
[_inputStream setDelegate:self];
[_inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

_outputStream = (__bridge_transfer NSOutputStream *)outputStream;
[_outputStream setDelegate:self];
[_outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

[_inputStream open];
[_outputStream open];

由于

1 个答案:

答案 0 :(得分:0)

这似乎是缓解BEAST攻击的1 / n-1分裂技术。 http://threatpost.com/apple-turns-on-safari-beast-attack-mitigation-by-default-in-os-x-mavericks/102804

您的服务器可能只支持TLS 1.0。如果您升级服务器以支持TLS 1.2,我相信iOS将停止这样做。