Joining multicast group on IPADDR_ANY - which interface?

Hello all,

I have the following question:

if you join a multicast group (with setsockopt() and IP_ADD_MEMBERSHIP) and specify INADDR_ANY as network interface to join on, the kernel is supposed to choose which interface to use (if there are multiple network interfaces, of course).
Does anybody here know how this default interface is chosen? How can I find out which interface on some machine will be used in this case, how can I configure a particular interface to be used as default for multicast join (if INADDR_ANY is used)?

I would appreciate any suggestions.

Alex.

The interface is chosen using the IP routing table.

Thanks for the reply Neo,

would you mind going into some more detail on this? I'm just not that familiar with networking issues...

Alex.