tvos - GCDAsyncUdpSocket - multicast nachrichten empfangen

  • tvos - GCDAsyncUdpSocket - multicast nachrichten empfangen

    Hey,

    ich stecke grade fest und bin etwas ratlos und hoffe jemand kennt das problem oder kann mir einen tipp geben in welche Richtung ich suchen kann

    ich will mit einer tvos app Udp multicast empfangen und senden -

    er startet ohne Fehler doch kommen keinerlei nachrichten an

    vielen dank

    Quellcode

    1. - (void)setupSocket
    2. {
    3. self.udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
    4. self.udpSocket.delegate = self;
    5. NSError *error = nil;
    6. if (![self.udpSocket bindToPort:4809 error:&error])
    7. {
    8. NSLog(@"Error binding to port: %@", error);
    9. return;
    10. }
    11. if(![self.udpSocket joinMulticastGroup:@"224.0.0.180" error:&error]){
    12. NSLog(@"Error connecting to multicast group: %@", error);
    13. return;
    14. }
    15. if (![self.udpSocket beginReceiving:&error])
    16. {
    17. NSLog(@"Error receiving: %@", error);
    18. return;
    19. }
    20. NSLog(@"CITP/MSEX SERVER started on port %hu", [self.udpSocket localPort]);
    21. [self.udpSocket enableBroadcast:YES error:&error];
    22. NSData *data = [[NSString stringWithFormat:@"Hello World"] dataUsingEncoding:NSUTF8StringEncoding];
    23. [self.udpSocket sendData:data toHost:@"224.0.0.180" port:4809 withTimeout:-1 tag:1];
    24. }
    25. // GCDAsyncUdpSocketDelegate
    26. - (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data
    27. fromAddress:(NSData *)address withFilterContext:(id)filterContext
    28. {
    29. const unsigned char *bytes = [data bytes];
    30. int value = (bytes[0] << 8) | bytes[1];
    31. NSLog(@"got data %d", value);
    32. }
    Alles anzeigen