On a computer with both an active Wireless Card and a LAN-Port with a crossover cable hooked up to another machine running the same application, we need to send a UDP multicast over the LAN wire to the other computer. Using C# Sockets, Windows seems to try to route the message over the WLAN adapter every time.
Is there a way to specify what network interface to send a UDP multicast on?
Just as addendum to Nikolai answer: the problem with KB318911 is a dirty trick that user must provide necessary adapter index. While looking how to retrieve this adapter index I figured out such recipe:
Full note at http://windowsasusual.blogspot.ru/2013/01/socket-option-multicast-interface.html
If you are using UDPClient class, then this method forces the IGMP message out of the interface you desire (second parameter), even when binding doesn't work.
Otherwise,
MulticastOption(IPAddress, IPAddress)
will work. The first parameter is the multicast address, the second address forces a localendpoint you specify to be used.You are probably looking for
SocketOptionName.MulticastInterface
. Here's an article on MSDN that might help you.Other then that if you update your local routing table to have an exact entry matching the multicast address and pointing to the right interface it should just work.
Depending on what you're doing, there's a Win32 method that might help. It'll return the best interface for a given IP address. To get the default one (the 0.0.0.0), which is usually what you want for multicast, it's pretty easy:
P/Invoke signature:
Then somewhere else: