title: Receiving UDP broadcast
body: <p>I have to receive an UDP broadcast (in Ubuntu if that makes any difference). Using Wireshark, I can see the packet being sent from the server machine, and I can see it being received by my client machine, but my program is completely oblivious. This is what I have:</p>
  
  <pre><code>sockaddr_in si_me, si_other;
  int s;
  assert((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))!=-1);
  int port=6000;
  int broadcast=1;
  
  setsockopt(s, SOL_SOCKET, SO_BROADCAST,
              &amp;broadcast, sizeof broadcast);
  
  memset(&amp;si_me, 0, sizeof(si_me));
  si_me.sin_family = AF_INET;
  si_me.sin_port = htons(port);
  si_me.sin_addr.s_addr = INADDR_ANY;
  
  assert(::bind(s, (sockaddr *)&amp;si_me, sizeof(sockaddr))!=-1);
  
  while(1)
  {
      char buf[10000];
      unsigned slen=sizeof(sockaddr);
      recvfrom(s, buf, sizeof(buf)-1, 0, (sockaddr *)&amp;si_other, &amp;slen);
  
      printf("recv: %s\n", buf);
  }
  </code></pre>
  
  <p>It is compiled in debug mode, the asserts aren't being erased during compilation, and my program just blocks on <code>recvfrom</code>.</p>
  
  <p>Is there any other hoop I have to jump through to receive an untargeted UDP broadcast?</p>
  
  <p>Edit: just a bit more info, I have the two computers connected on a dedicated switch, no outside interference. I also have a second network card on my client computer that connects to the company network, which also works. </p>
  
  <p>I can ping both the outside (Internet working) and my server machine (plus I can see the actual packets in Wireshark), but you never know what might cause this problem.</p>