Even though there is already an accepted answer I feel like it does not answer the original question.
If you are on Linux, you can force the IGMP version by changing the value in this file:
/proc/sys/net/ipv4/conf/eth1/force_igmp_version
Note that where I have "eth1" you must use the interface that you are interested in. The value 0 means auto and 1, 2 or 3 force this specific version of IGMP.
So if you want IGMPv3 on eth0, for example, you can do:
echo 3 > /proc/sys/net/ipv4/conf/eth1/force_igmp_version
On Windows, you can run regedit
and on HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
create a new DWORD named IGMPVersion
. Setting to 2
would mean IGMPv1, 3
would mean IGMPv2 and 4
would mean IGMPv3.
On a side note, both systems, when operating on auto, should always use the highest version available. That means that usually there is no reason to force IGMPv3. You might need to force v2 though, if you happen to be interacting with some old equipment which does not support v3.
And to conclude, the only way you could force the version of IGMP you want to send joins in on you c code (I mean without adjusting the system configurations before), is if you use a raw socket and mount the whole packet yourself.