我猜想,是在一台win2k3服务器上配置多播地址,然后程序往这个服务器上发,这个服务器负责多播。
是这样的么?
2 个解决方案
#2
struct ip_mrep_source mreqsrc;
mreqsrc.imr_interface.s_addr = inet_addr("192.168.0.2");
mreqsrc.imr_multiaddr.s_addr = inet_addr("234.5.6.7");
// 添加源地址 218.12.255.13
mreqsrc.imr_sourceaddr.s_addr = inet_addr("218.12.255.13);
::setsockopt(sock, IPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP, (char*)&mreqsrc, sizeof(mreqsrc));
// 添加源地址 218.12.174.222
mreqsrc.imr_sourceaddr.s_addr = inet_addr("218.12.174.222);
::setsockopt(sock, IPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP, (char*)&mreqsrc, sizeof(mreqsrc));
#1
#2
struct ip_mrep_source mreqsrc;
mreqsrc.imr_interface.s_addr = inet_addr("192.168.0.2");
mreqsrc.imr_multiaddr.s_addr = inet_addr("234.5.6.7");
// 添加源地址 218.12.255.13
mreqsrc.imr_sourceaddr.s_addr = inet_addr("218.12.255.13);
::setsockopt(sock, IPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP, (char*)&mreqsrc, sizeof(mreqsrc));
// 添加源地址 218.12.174.222
mreqsrc.imr_sourceaddr.s_addr = inet_addr("218.12.174.222);
::setsockopt(sock, IPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP, (char*)&mreqsrc, sizeof(mreqsrc));