Tag: gcdasyncsocket

iOS上的GCDAsyncUdpSocket丢失了多播数据报

我有一个networking上的设备,通过UDP组播一个非常小的文件。 我正在开发的iOS应用程序负责读取这些数据包,我select使用GCDAsyncUdpSocket来做到这一点。 该文件每半秒发送一次,但我几乎没有收到它(往往每3-10秒接收一次)。 考虑到这可能是设备的问题,我开始使用Wireshark监控stream量。 这似乎反映了我在应用程序中看到的内容,直到我在Wireshark中启用“Monitor Mode”为止,此时每个UDP数据包都被捕获。 此外,iOS模拟器开始接收所有丢失的数据包,因为它与我正在开发的Mac共享网卡。 有没有办法在iOS设备上启用“监视器模式”,或者我缺less一些可以丢失数据包的东西? 我也看到在GCDAsyncUdpSocket中有一个readStream方法。 也许我需要使用这个而不是beginReceiving? 尽pipe如此,我不知道如何在Objective-C中设置stream。 这是我现在的testing代码: – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. NSLog(@"View Loaded"); [self setupSocket]; } – (void)setupSocket { udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()]; NSError *error = nil; if (![udpSocket bindToPort:5555 error:&error]) { NSLog(@"Error binding […]