title: C# UDP broadcast client/server does not work
body: <p>I'm using .NET 2.0 and have created a fairly simple udp broadcast app and UDP listener.  </p>
  
  <p>Listener code:</p>
  
  <pre><code>Socket listener = new Socket( AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp );
  IPEndPoint localEndPoint = new IPEndPoint( IPAddress.Any, 11000 );
  listener.Bind( localEndPoint );
  EndPoint ep = (EndPoint)localEndPoint;
  Console.WriteLine("Ready to receive…");
  byte[] data = new byte[1024];
  int recv = listener.ReceiveFrom(data, ref ep);
  string stringData = Encoding.ASCII.GetString(data, 0, recv);
  Console.WriteLine("received: {0} from: {1}", stringData, ep.ToString());
  listener.Close();
  </code></pre>
  
  <p>Server code:</p>
  
  <pre><code>int groupPort = 11000;
  IPEndPoint groupEP = new IPEndPoint( IPAddress.Parse( "255.255.255.255" ), groupPort );
  
  if ( radioButton2.Checked )
  {
      groupEP = new IPEndPoint( IPAddress.Broadcast, groupPort );
  }
      else if ( radioButton3.Checked )
  {
      groupEP = new IPEndPoint( IPAddress.Parse( "172.16.75.15" ), groupPort );
  }
  
  Socket socket = new Socket( AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp );
  socket.SetSocketOption( SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1 );
  socket.SendTo( System.Text.ASCIIEncoding.ASCII.GetBytes( testTextBox.Text ), groupEP );
  </code></pre>
  
  <p>The server is just a simple windows app with 3 radio buttons, button and a textbox. </p>
  
  <p>When I run the server on a separate computer and choose radioButton3 I receive the message just fine on my client listener (which is running on ip address 172.16.75.15). However if I choose the first or second radiobutton (which creates Broadcast or 255.255.255.255 as the ip address) I get nothing. Now if I run the client on the same pc as the server I can receive the message using those two choices. </p>
  
  <p>I'm not sure what I'm doing wrong or if there could be some kind of firewall preventing UDP messages on the LAN. Any ideas?</p>
  
  <p>Thanks,</p>
  
  <p>Craig</p>