title: C# UDP Broadcast and receive example
body: <p>Problem:
  I am trying to bind a udp socket on a specific address. I will broadcast out a message. That same socket will need to be able to receive messages.</p>
  
  <p>Current code:</p>
  
  <pre><code>static void Main()
  {
      UdpClient Configuration = new UdpClient(new IPEndPoint(IPAddress.Parse(data.IPAddress), configuration.Port));  //set up the bind to the local IP address of my choosing
      ConfigurationServer.EnableBroadcast = true;
      Configuration.Connect(new IPEndpoint(IPAddress.Parse(data.BroadcastIP), configuration.Port);
      Listen();
  
   }
  
  private void Listen()
  {
      Task.Run(async () =&gt;
              {
                  while (true)
                  {
                      var remoteIp = new IPEndPoint(IPAddress.Any, configuration.Port);
                      var data = await ConfigurationServer.ReceiveAsync();
  
                      // i would send based on what data i received here
                      int j = 32;
                  }
              }
  });
  }   
  </code></pre>
  
  <p>I am not receiving data on listen thread. I know that the code on the other side is functional, and sending a directed UDP message to the IP/Port combo.</p>