I want to run UDP Recevie on RPi 3 and with Android app "UDP Sender" when send text, I want to control GPIO Pins.

I need help, how to make UDP Recevie for Windows 10 IoT? I search a lot but can't make it work.

Thanks in advance for help!


I sloved the problem!

Here is code:

   public sealed partial class MainPage : Page
    DatagramSocket listenerSocket = null;
    const string port = "8080";
    public MainPage()

private async void Listen()
    listenerSocket = new DatagramSocket();
    //listenerSocket.MessageReceived += (x, y) =>
    //    var a = "2";
    listenerSocket.MessageReceived += MessageReceived;
    await listenerSocket.BindServiceNameAsync(port);

private async void Send()
    IOutputStream outputStream;
    string localIPString = GetLocalIp();
    IPAddress localIP = IPAddress.Parse(localIPString);
    string subnetMaskString = "";
    IPAddress subnetIP = IPAddress.Parse(subnetMaskString);
    HostName remoteHostname = new HostName(localIP.ToString());
    outputStream = await listenerSocket.GetOutputStreamAsync(remoteHostname, port);

    using (DataWriter writer = new DataWriter(outputStream))
        await writer.StoreAsync();


//private object GetBroadcastAddress(IPAddress localIP, IPAddress subnetIP)
//    throw new NotImplementedException();

async void MessageReceived (DatagramSocket socket, DatagramSocketMessageReceivedEventArgs args)
    DataReader reader = args.GetDataReader();
    uint len = reader.UnconsumedBufferLength;
    string msg = reader.ReadString(len);

    string remoteHost = args.RemoteAddress.DisplayName;

    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
        text.Text = msg;


private string GetLocalIp()


And also don't forget to:

I found the solution. Apparently, you have to specifically enable that the application will be receiving incoming network traffic. The UWP project in Visual Studio contains a file named Package.appxmanifest. Double click it, select the Capabilities tab and check Internet (Client & Server). More about that at the MSDN - Networking basics.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.