title: Setting SO_BROADCAST to a socket fails with "Invalid argument"
body: <p>My IDE: xCode, OS X 10.10.4</p>
  
  <pre><code>int s = socket(AF_INET, SOCK_DGRAM, 0);
  bool bc = true;
  int ret = setsockopt(s, SOL_SOCKET, SO_BROADCAST, (const void*)&amp;bc, sizeof(bool));
  if(ret &lt; 0){
      perror("set opt err:");
  }
  sockaddr_in tarAddr;
  memset(&amp;tarAddr, 0, sizeof(sockaddr_in));
  tarAddr.sin_family = AF_INET;
  tarAddr.sin_port = htons(5000);
  tarAddr.sin_addr.s_addr = INADDR_BROADCAST;
  
  char szMsg[100] = {0};
  strcpy(szMsg, "hello");
  
  int len = sizeof(sockaddr);
  ret = sendto(s, szMsg, strlen(szMsg), 0, (sockaddr*)&amp;tarAddr, len);
  if(ret &lt; 0){
      perror("sendto err:");
  }
  close(s);
  </code></pre>
  
  <p>The above code is about send udp message to broadcast, but the result info is:</p>
  
  <pre><code>set opt err: Invalid argument
  sendto err: Permission denied
  </code></pre>
  
  <p>and the same code go fine in vc++/windows.</p>