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.
The localIP is the local Ip from the selected adapter
The senders 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);
EDIT1:
Code for adapters local IP:
NetworkInterface.GetAllNetworkInterfaces()[adapterIndex].GetIPProperties().UnicastAddresses[0].Address;
EDIT2,5:
Also tried both of with same reuslt
Wireshark displays me the correct join of the multicast group on the second adapter
udpclient.JoinMulticastGroup(multicastaddress);
udpclient.Client.Bind(remoteep);
EDIT3:
I now tried on another PC but the same problem happens again, Adapter1 runs, on all others nothing is sent.
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.
JoinMulticastGroup
method. – L.B