gpt4 book ai didi

iOS - GCDAsyncUdpSocket 抛出错误域=NSPOSIXErrorDomain 代码=65 "No route to host"

转载 作者:行者123 更新时间:2023-12-05 07:46:24 30 4
gpt4 key购买 nike

有时我会收到这个错误

Error Domain=NSPOSIXErrorDomain Code=65 "No route to host" UserInfo={NSLocalizedDescription=No route to host, NSLocalizedFailureReason=Error in send() function.}

在某些路由器中打开 udp 套接字时。我不知道是什么原因造成的。

这是我打开 udp 套接字的代码:

- (void)openSocket
{
if(_asyncUdpSocket == nil)
{
_asyncUdpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)];
}

if(![_asyncUdpSocket isClosed])
{
return;
}

NSError *error;

if (![_asyncUdpSocket enableBroadcast:YES error:&error])
{
NSLog(@"AsyncUdp: enable broadcast failed error: %@", error);
}

if (![_asyncUdpSocket bindToPort:_port error:&error])
{
NSLog(@"AsyncUdp: bind to port %li failed error: %@", (unsigned long)_port, error);
}

if (![_asyncUdpSocket joinMulticastGroup:_address error:&error])
{
NSLog(@"AsyncUdp: join multicast group %@ failed error: %@", _address, error);
}

if(![_asyncUdpSocket beginReceiving:&error])
{
NSLog(@"AsynUdp: begin receiving error: %@", error);
}

if(error != nil)
{
NSLog(@"Udp failed to open!");

[_delegate onUdpSocketDidOpenfailed];
}

else
{
NSLog(@"UdpSocket - opend udp socket successful!");

[_delegate onUdpSocketDidOpen];
}
}

请注意,这种情况在 iPhone 7 中经常发生

最佳答案

将 Xcode 更新到版本 12.5 后,我在运行 DLNA App 项目时遇到了同样的问题。我通过将 Xcode 降级到版本 12.4 来修复它。

关于iOS - GCDAsyncUdpSocket 抛出错误域=NSPOSIXErrorDomain 代码=65 "No route to host",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40787222/

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