gpt4 book ai didi

ios - GCDASyncSocket SSL 不连接

转载 作者:太空宇宙 更新时间:2023-11-03 13:42:26 26 4
gpt4 key购买 nike

我的套接字连接正常,但服务器已更新为 SSL。我称这个方法为:

[socket startTLS:nil];

但我仍然无法与服务器建立安全连接。我这样启动连接:

- (void) initNetworkCommunication {

dispatch_queue_t mainQueue = dispatch_get_main_queue();
socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:mainQueue];

NSError *err = nil;
if (![socket connectToHost:@"192.168.2.210" onPort:1333 viaInterface:@"" withTimeout:-1 error:&err]) // Asynchronous!
{
// If there was an error, it's likely something like "already connected" or "no delegate set"
NSLog(@"I goofed: %@", err);
}else
{
NSLog(@"Connecting...");
}
[socket readDataWithTimeout:-1 tag:1];

}

你能帮我吗?

最佳答案

我在进行 initNetworkCommunication 之后调用了 [socket startTLS:nil],但应该是在我们建立连接的那一刻,就像这样:

- (void) initNetworkCommunication {

dispatch_queue_t mainQueue = dispatch_get_main_queue();
socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:mainQueue];

NSError *err = nil;
if (![socket connectToHost:@"192.168.2.210" onPort:1333 viaInterface:@"" withTimeout:-1 error:&err]) // Asynchronous!
{
// If there was an error, it's likely something like "already connected" or "no delegate set"
NSLog(@"I goofed: %@", err);
}else
{
[socket startTLS:nil];
NSLog(@"Connecting...");

}
[socket readDataWithTimeout:-1 tag:1];

}

关于ios - GCDASyncSocket SSL 不连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13767490/

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