This is in Java, but I can always revert to C via JNI if needed.
I have a system with two NICs, each connected to a distinct subnet. I want to use multicast (in particular, SDP) to discover other hosts on both networks.
One network is easy: create a MulticastSocket on the specified port, joinGroup it, and I get packets. Simplicity.
Two networks: so far impossible. I've tried:
1) creating two sockets, binding to the same port and using setInterface() or setNetworkInterface() to "connect" to the right interface. No luck, even after various permutations of setReuseAddress().
2) create a single socket, and then attempt to join twice, with two calls to joinGroup(SocketAddress mcastaddr, NetworkInterface netIf). The second join call fails.
Solutions outside of Java would be great. In particular, if I could set up multicast routes that would effectively 'combine' the two interfaces (I could then look at each packet to determine which network) that would be fine. As I mentioned before, any amount of native code is usable in this environment (Linux, with the Apache "luni" java infrastructure).
Thanks!