title: watching broadcast behavior by tcpdump in Linux
body: <p>I have a c sample code to receive broatcast packets in RedHat Enterprise Linux5.5 ,
  the following is the key source :</p>
  
  <pre><code>struct ip_mreq {
      struct in_addr imr_multiaddr;    /* IP multicast address of group */
      struct in_addr imr_interface;    /* local IP address of interface */
  } mreq; 
  
  serv_addr.sin_addr.s_addr = inet_addr("225.0.100.100");
  portno = 10000 ;
  serv_addr.sin_port = htons(portno);
  mreq.imr_multiaddr = serv_addr.sin_addr; 
  mreq.imr_interface.s_addr = INADDR_ANY ;
  //mreq.imr_interface.s_addr = inet_addr("192.168.165.212");
  setsockopt(newsockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &amp;mreq, sizeof(mreq));
  setsockopt(newsockfd, SOL_SOCKET, SO_REUSEADDR, &amp;set, sizeof(set));
  </code></pre>
  
  <p>The routing table is :</p>
  
  <p>[root@linux01 ~]# route
  Kernel IP routing table
  Destination     Gateway         Genmask         Flags Metric Ref    Use Iface</p>
  
  <p>192.172.165.0   *               255.255.255.0   U     0      0        0 eth0</p>
  
  <p>128.110.10.0    *               255.255.255.0   U     0      0        0 eth2</p>
  
  <p>225.0.0.0       192.172.165.212 255.255.0.0     UG    0      0        0 eth0</p>
  
  <p>169.254.0.0     *               255.255.0.0     U     0      0        0 eth0</p>
  
  <p>default         128.110.10.254  0.0.0.0         UG    0      0        0 eth2</p>
  
  <p>I  use tcpdump -i eth0 -nn   to watch  if  join broadcast group succefully , </p>
  
  <pre><code>mreq.imr_interface.s_addr = INADDR_ANY ;
  //mreq.imr_interface.s_addr = inet_addr("192.168.165.212");
  </code></pre>
  
  <p>will showes :</p>
  
  <p>16:14:24.322672 IP 192.172.165.212 > 225.0.100.100: igmp v2 report 225.0.100.100</p>
  
  <pre><code>mreq.imr_interface.s_addr = INADDR_ANY ;
  //mreq.imr_interface.s_addr = inet_addr("192.168.165.212");
  </code></pre>
  
  <p>this won't have igmp v2 report messages !!</p>
  
  <p>My question is :  Why INADDR_ANY works , but not inet_addr("192.168.165.212");</p>
  
  <p>Anything I missed ?</p>
  
  <p>eth0 inet addr:192.172.165.212  Bcast:192.172.165.255  Mask:255.255.255.0
  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1</p>
  
  <p>eth2 inet addr:128.110.10.69  Bcast:128.110.10.255  Mask:255.255.255.0
  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1</p>