I am using the RL-TCPNet, the MDK Version is 5.20. And in my application ,I create an UDP server,and join 2 multicast group, 225.0.0.1 and 225.0.0.2. The udp server port is 1001. This is my code:
sock = socket (AF_INET, SOCK_DGRAM , IPPROTO_UDP);
addr.sin_port = htons(1001); addr.sin_family = AF_INET; //addr.sin_addr.s_addr = INADDR_ANY; addr.sin_addr.s_b1 = 225; addr.sin_addr.s_b2 = 0; addr.sin_addr.s_b3 = 0; addr.sin_addr.s_b4 = 1;
bind (sock, (SOCKADDR *)&addr, sizeof(addr));
addrlen = sizeof (addr); res = recvfrom (sock, dbuf, sizeof (dbuf), 0,(struct sockaddr*)&addr, &addrlen);
Now I can receive data form the 2 multicast group, but I can't find out which group the data comes from?
I search the Web and I find in other Ethernet stack ,the setsockopt has the "IP_ADDR_MEMBERSHIP" option: setsockopt(s, IPPROTO_IP, IP_ADDR_MEMBERSHIP, (char*)&ipmr, sizeof(ipmr)); But,in RL-TCPNet,the 3rd parameter has no this option: SO_KEEPALIVE = Keep Alive. SO_RCVTIMEO = Timeout for blocking receive (in ms). IP_TOS = Type of Service (TOS). IP_TTL = Time to Live (TTL). IPV6_TCLASS = Traffic Class. IPV6_MULTICAST_HOPS = Multi-cast Hop Limit.
HOW can I find find out where the data comes from? Or, how can I set the socket option to receive the appointed membergroup? So I can create ont socket to receive data from one multicast group, and create another scoket to receive data from the other multicast group.