gpt4 book ai didi

ios - 无法访问 CFStreamCreatePairWithSocketToHost 上的 exc_i386_gpflt

转载 作者:太空宇宙 更新时间:2023-11-03 14:12:06 30 4
gpt4 key购买 nike

我正在尝试与我的服务器建立 TLS 连接,但在

CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, str, 5555, &readStream, &writeStream); 

无法访问 exc_i386_gpflt。我该如何解决?

完整代码

CFReadStreamRef readStream = NULL;
CFWriteStreamRef writeStream = NULL;
CFStringRef str = (CFStringRef)"127.0.0.1";
CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, str, 5555, &readStream, &writeStream);
if (readStream && writeStream) {
CFReadStreamSetProperty(readStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);

NSInputStream *inputStream = (__bridge NSInputStream *)readStream;
[inputStream setDelegate:self];
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[inputStream open];

NSOutputStream *outputStream = (__bridge NSOutputStream *)writeStream;
[outputStream setDelegate:self];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[outputStream open];
}

if (readStream)
CFRelease(readStream);

if (writeStream)
CFRelease(writeStream);

最佳答案

试试这个:

CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)HOST, PORT, &readStream, &writeStream);

关于ios - 无法访问 CFStreamCreatePairWithSocketToHost 上的 exc_i386_gpflt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28297572/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com