title: c# socket sends // binds udp multicasts not to the selected network interface
body: <p>Hello i got 2 Networkadapters on my PC and want to send udp multicasts to group 239.0.0.222 Port 9050 on the selected Network interface.
  But it only works with the first interface, when choosing another NIC no data is sent.</p>
  
  <p>The localIP is the local Ip from the selected adapter</p>
  
  <p>The senders code:</p>
  
  <pre><code> IPAddress localIP = getLocalIpAddress();
   IPAddress multicastaddress = IPAddress.Parse("239.0.0.222");
   IPEndPoint remoteep = new IPEndPoint(multicastaddress, 9050);
   UdpClient udpclient = new UdpClient(9050);
   MulticastOption mcastOpt = new MulticastOption(multicastaddress,localIP);
  
   udpclient.Client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, mcastOpt);
   udpclient.Send(data, data.Length, remoteep);
  </code></pre>
  
  <p>EDIT1:<br>
  Code for adapters local IP:</p>
  
  <pre><code>NetworkInterface.GetAllNetworkInterfaces()[adapterIndex].GetIPProperties().UnicastAddresses[0].Address;
  </code></pre>
  
  <p>EDIT2,5:<br>
  Also tried both of with same reuslt
  Wireshark displays me the correct join of the multicast group on the second adapter</p>
  
  <pre><code>udpclient.JoinMulticastGroup(multicastaddress);
  udpclient.Client.Bind(remoteep);
  </code></pre>
  
  <p>EDIT3:<br>
  I now tried on another PC but the same problem happens again, Adapter1 runs, on all others nothing is sent.<br>
  Another thing i tried out, is to switch the order of the first two adapters in the windows xp config, then again the new first adapter works but the new second sends nothing.</p>