我遇到了一个问题。相同的代码在 iPhone (iOS 5) 和 iPhone/iPad 模拟器上运行良好。但它不适用于 iPad (iOS 5)。我会很感激任何帮助。
这是读取端口代码:
//Code for read port.
CFIndex bytesRead = CFReadStreamRead(inputStream, bufferPoint, 1024);
if (bytesRead < 0) {
NSLog(@"bytesRead < 0");
CFErrorRef error = CFReadStreamCopyError(inputStream);
//reportError(error);
DEBUGLOG(@"readResponse error \n")
在上面之前,有连接部分代码。
//prevent to release before relocate
if ((inputStream != nil) && (outputStream != nil)) {
[inputStream release];
inputStream = nil;
[outputStream release];
outputStream = nil;
}
[NSStream getStreamsToHostNamed:relayHost port:relayPort inputStream:&inputStream outputStream:&outputStream];
//[self lgetStreamsToHostNamed:relayHost port:relayPort inputStream:&inputStream outputStream:&outputStream];
if ((inputStream != nil) && (outputStream != nil))
{
sendState = kIMAPConnecting;
isSecure = NO;
[inputStream retain];
[outputStream retain];
[inputStream setDelegate:self];
[outputStream setDelegate:self];
result = [inputStream setProperty:NSStreamSocketSecurityLevelNegotiatedSSL forKey:NSStreamSocketSecurityLevelKey];
DEBUGLOG(@"inputStream setProperty result: %d", result);
result =[ outputStream setProperty:NSStreamSocketSecurityLevelNegotiatedSSL forKey:NSStreamSocketSecurityLevelKey];
DEBUGLOG(@"outputStream setProperty result: %d", result);
if (!CFReadStreamOpen(inputStream)) {
DEBUGLOG(@"inputStream open failed");
return NO;
}
if (!CFWriteStreamOpen(outputStream)) {
DEBUGLOG(@"outputStream open failed");
return NO;
}
self.inputString = [NSMutableString string];
DEBUGLOG(@"SCRIMAPMessage startToConnect end with YES\n");
return YES;
}