IP_MULTICAST_IF and IP_MULTICAST_IF not work if wsock32.dll used instead of ws2_32.dll . I thought I was doing it wrong when I kept getting 1.0.0.0 as the IP address, even when it was something else that I installed using setsockopt. Funny, before calling IP_MULTICAST_IF it will return 0.0.0.0 , so setsockopt` will change something, itβs just not right.
Someone who had this problem, back in 2004 - http://us.generation-nt.com/ip-multicast-problem-help-37595922.html . When we #include "winsock2.h" , we need to use ws2_32.dll . However, with C ++ Builder it is not possible to use ws2_32.dll when we use winsock2.h - RTL implicitly refers to wsock32.dll, and you cannot link ws2_32.dll, even if you explicitly specify #pragma comment(lib, "ws2_32.lib") . Embarcadero really needs to fix it! Someone from the RTL team must have decided that he was smart to implicitly enable wsock32.dll. The only βsmartβ thing she did was not to include one line in her code - #pragma comment(lib, "wsock32.lib") . Although they are, they can also include all the DLL files known to mankind.
source share