In fact, when using TCP and UDP peer-to-peer communication on iOS, it is necessary to confirm whether the application has enabled the "wireless data" permission. The steps are: Settings ->Your application ->Select wireless LAN and cellular network
When iOS 17 sends UDP, System Net Sockets SocketException (65): Norout to host
I am using Maui and NET 8 in Visual Studio 2022, And implement UDP and TCP messages sent on iOS 17. There is an issue with UDP not being able to send messages and displaying error messages: System NET Sockets SocketException (65): No route to host, Sent peer-to-peer information, not multicast,but everything is normal on Windows and Android, with the same WiFi assigned IP address and port. The code is as follows:
TcpListener tcpListener = new TcpListener(IPAddress.Parse("The IP address of WiFi
"), 8989);
tcpListener.Start();
IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse("WiFi router address
"), 57788);
udpClient.Send(requestBytes, requestBytes.Length, remoteEP);
await Task.Delay(20);
TcpClient udpClient.Client.ReceiveTimeout = 3000;
byte[] responseBytes = udpClient.Receive(ref remoteEP);
The code is in udpClient.Send(), error System Net Sockets SocketException (65): Norout to host. Please provide some suggestions. Thank you
I tried to configure the following permissions in info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
<key>NSLocalNetworkUsageDescription</key>
<string>This app needs access to the local network to communicate with devices.</string>
Trying is useless.
I tried using a temporary distribution package for installation, but it didn't solve the problem. Even using a hot restart doesn't work. I used software to ping the WiFi router address on my iOS 17 phone and it was successful.Please give me some suggestions.