title: Why is my UDP broadcast failing?
body: <p>I'm trying to send a UDP broadcast but wireshark isn't reporting any traffic. Here's the snippet that does the sending:</p>
  
  <pre><code>void SendBroadcast()
  {
      String^ ip = "255.255.255.255";
      int port = 30718;
      String^ message = "test";
  
      UdpClient^ udpClient = gcnew UdpClient();
      udpClient-&gt;EnableBroadcast = true;
      IPEndPoint^ ipDest = gcnew IPEndPoint(IPAddress::Parse(ip), port);
      cli::array&lt;unsigned char&gt;^ dgram = Encoding::ASCII-&gt;GetBytes(message);
      int bytesSent = udpClient-&gt;Send(dgram, dgram-&gt;Length, ipDest);
  
      if( bytesSent != message-&gt;Length )
      {
          // Failed to send
          Console::WriteLine(String::Format("Error: Failed to send all data (bytes sent: {0})", bytesSent));
      }
      else
      {
          Console::WriteLine(String::Format("Bytes sent: {0}", bytesSent));
      }
  }
  </code></pre>
  
  <p>It reports that it's sent the data (4 bytes) so why doesn't Wireshark see the traffic? I've tried with another application which broadcasts on the same port and the traffic from that application shows up fine.</p>
  
  <p>What am I missing?</p>
  
  <p><strong>[Edit]</strong> I just spotted a post on the bottom of <a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.aspx" rel="nofollow">the UdpClient documentation</a> which states that sending to 255.255.255.255 on a windows 7 machine doesn't work. That can't be true of the o/s as a whole though or the broadcast from the other application to 255.255.255.255 would be failing?</p>