title: Universal Windows App receiving UDP data on a port from any server
body: <p>I am trying to implement an UDP listener on a specific port but from any machine. I am trying to use the "new" Universal Windows project using Visual Studio 2015.</p>
  
  <p>Using a WPF "old" type of project I could do the following:</p>
  
  <pre><code>public void StartListening()
  {
      this.client = new System.Net.Sockets.UdpClient(5606);
      this.endpoint = new System.Net.IPEndPoint(System.Net.IPAddress.Any, 5606);
      this.client.BeginReceive(new AsyncCallback(receive), this);
  }
  
  private static void receive(IAsyncResult result)
  {
      var self = ((UDPListener)result.AsyncState);
      var receivedBytes = self.client.EndReceive(result, ref self.endpoint);
      // do something with receivedBytes
      self.StartListening();
  }
  </code></pre>
  
  <p>However using Universal Windows it seems to be quite different. There is no <code>System.Net.Sockets.UdpClient</code> any more. The only thing I can find is connecting to/from a client/server UDP things and stuffs using <code>Windows.Networking.Sockets.DatagramSocket</code>. With which I came up with the following:</p>
  
  <pre><code>public async void Connect()
  {
      var listenerSocket = new Windows.Networking.Sockets.DatagramSocket();
  
      listenerSocket.MessageReceived += ListenerSocket_MessageReceived;
  
      await listenerSocket.BindServiceNameAsync("5606");
  }
  
  private void ListenerSocket_MessageReceived(Windows.Networking.Sockets.DatagramSocket sender, Windows.Networking.Sockets.DatagramSocketMessageReceivedEventArgs args)
  {
      throw new NotImplementedException();
  }
  </code></pre>
  
  <p>But this does not seem to do what I want. I never receive any data from a server that is running in the background. Where the WPF version does receive data.</p>
  
  <p>What am I doing wrong? Is this  not even possible any more? Can Universal Windows applications only receive data from other Universal Windows applications? Or am I just looking at the wrong things here?</p>