In my Xamarin.Forms app for UWP I have the following simple code to receive a UDP datagram:
using (var udpClient = new UdpClient(port))
{
var datagram = await udpClient.ReceiveAsync();
}
For testing purposes I need to run this app from within Visual Studio and from the same computer send a datagram to the app with some (non-UWP) terminal program. But it doesn't work - ReceiveAsync()
never returns.
I know that UWP prohibits loopback communication by default, but for debugging it should be possible according to https://stackoverflow.com/a/44990978/487356.
In the UWP project I enabled the "Internet (Client)", "Internet (Client & Server)" and "Private Networks (Client & Server)" capabilities. Also I enabled "Allow local network loopback" in the debug settings. And using the CheckNetIsolation tool I was able to verify that my app is listed under LoopbackExempt. So this all looks good, but I still can't receive any UDP datagrams.
Is there something else I need to do for this to work?
Edit Reading a bit more about this, it looks like receiving data from the same machine is prohibited even when the app is listed under LoopbackExempts, see Problems with UDP in windows 10. UWP. This is really annoying!
So I guess the follow-up question would be: What is a good (preferrably connection-less) alternative for IPC?