Post

Replies

Boosts

Views

Activity

Reply to iOS udp broadcast stopped work after upate my device to ios 16
Hello Eskimo, thank you for your prompt response. Regarding the questions: Yes, I have tested it on iOS 16.3 and it did not work, It only works on iOS versions below 16. I am using Flutter in my application, but it is not clear which API is being utilized. Yes, I am receiving the following errors: "SocketException (SocketException: Send failed (OS Error: No route to host, errno = 65), address = 10.31.2.85, port = 0)" I am sending and receiving data, my app searches for a TV on the same network, and after connecting, I send data to the TV. The exception occurred during the initial flow, when searching for a TV. Here is a part of my code implementation: final InternetAddress _ipv4Multicast = new InternetAddress("239.255.255.250");   final InternetAddress _ipv6Multicast = new InternetAddress("FF05::C");   List<RawDatagramSocket> _sockets = <RawDatagramSocket>[];   late Timer? _discoverySearchTimer;   Future createSocket(void Function(String) fn, NetworkInterface bindInterface,       String bindAddress) async {     RawDatagramSocket _socket = await RawDatagramSocket.bind(bindAddress, 0);     _socket.broadcastEnabled = true;     _socket.multicastHops = 50;     _socket.readEventsEnabled = true;     await _socket.listen((event) async {       print("-- listen(): received event " + event.toString());       switch (event) {         case RawSocketEvent.read:           var packet = _socket.receive();           _socket.writeEventsEnabled = true;           _socket.writeEventsEnabled = true;           if (packet == null) {             return;           }           var data = utf8.decode(packet.data);           print("-- listen(): data received");           fn(data);           break;       }     });     try {       _socket.joinMulticast(_ipv4Multicast, bindInterface);     } on OSError {}     try {       _socket.joinMulticast(_ipv6Multicast, bindInterface);     } on OSError {}     _sockets.add(_socket);   }   void stop() {     if (_discoverySearchTimer != null) {       _discoverySearchTimer!.cancel();       _discoverySearchTimer = null;     }   }   void request([String? searchTarget]) {     if (searchTarget == null) {       searchTarget = "ssdp:all";     }     var buff = new StringBuffer();     buff.write("M-SEARCH * HTTP/1.1\r\n");     buff.write("HOST:239.255.255.250:1900\r\n");     buff.write('MAN:"ssdp:discover"\r\n');     buff.write("MX:1\r\n");     buff.write("ST:$searchTarget\r\n\r\n");     var data = utf8.encode(buff.toString());     for (var socket in _sockets) {       try {         var res = socket.send(data, _ipv4Multicast, 1900);         print("-- request(): sended bytes $res");       } on SocketException {}     }   }
Jan ’23