title: How to do a UDP multicast across the local network in c#?
body: <p>I am trying to get some simple UDP communication working on my local network.</p>
  
  <p>All i want to do is do a multicast to all machines on the network</p>
  
  <p>Here is my sending code</p>
  
  <pre><code>    public void SendMessage(string message)
      {
          var data = Encoding.Default.GetBytes(message);
          using (var udpClient = new UdpClient(AddressFamily.InterNetwork))
          {
              var address = IPAddress.Parse("224.100.0.1");
              var ipEndPoint = new IPEndPoint(address, 8088);
              udpClient.JoinMulticastGroup(address);
              udpClient.Send(data, data.Length, ipEndPoint);
              udpClient.Close();
          }
      }
  </code></pre>
  
  <p>and here is my receiving code</p>
  
  <pre><code>    public void Start()
      {
          udpClient = new UdpClient(8088);
          udpClient.JoinMulticastGroup(IPAddress.Parse("224.100.0.1"), 50);
  
          receiveThread = new Thread(Receive);
          receiveThread.Start();
      }
  
      public void Receive()
      {
          while (true)
          {
              var ipEndPoint = new IPEndPoint(IPAddress.Any, 0);
              var data = udpClient.Receive(ref ipEndPoint);
  
              Message = Encoding.Default.GetString(data);
  
              // Raise the AfterReceive event
              if (AfterReceive != null)
              {
                  AfterReceive(this, new EventArgs());
              }
          }
      }
  </code></pre>
  
  <p>It works perfectly on my local machine but not across the network.</p>
  
  <p>-Does not seem to be the firewall. I disabled it on both machines and it still did not work.</p>
  
  <p>-It works if i do a direct send to the hard coded IP address of the client machine (ie not multicast).</p>
  
  <p>Any help would be appreciated.</p>