title: default values for IP_MULTICAST_IF
body: <p>I am trying to figure out, what default values are used for the IP_MULTICAST_IF option after setting up a new socket. Unfortunately my code segfaults and I actually don't know why?! Am I doing something wrong, or how to I get the default values for the IP_MULTICAST_IF option?</p>
  
  <pre><code>  int sock;
    struct in_addr interface_addr;
    int addr_size;
  
    if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) &lt; 0) {
      perror("socket() failed");
    }
  
    addr_size = sizeof(interface_addr);
  
    if ((getsockopt(sock, IPPROTO_IP, IP_MULTICAST_IF, &amp;interface_addr, &amp;addr_size)) &lt;  0) {
      perror("getsockopt() failed");
    }
  
    printf("The default interface is %s\n", inet_ntoa(interface_addr));
  </code></pre>