I have a multicast-based IPTV in my network. All channels have muticast addresses like 239.0.1.*. Streamer device sends UDP data to target port 1234. So to receive a tv stream I do usual stuff like:
{ok, S} = gen_udp:open(1234, ....
inet:setopts(S, [{add_membership, {{239,0,1,2}, {0,0,0,0}}}]),
It works.
Now I want to subscribe to multiple channels to receive several streams simultaneously. So I do another call:
inet:setopts(S, [{add_membership, {{239,0,1,3}, {0,0,0,0}}}]),
It works too. I see both streams in Wireshark. I can distinguish them by destination IP addresses - 239.0.1.2 and 239.0.1.3.
BUT.
In Erlang I cant figure out a channel to which incoming packet belongs, cause UDP data arrives as messages:
{udp, Socket, IP, PortNo, Packet},
where IP and PortNo is the source address (10.33.33.32 in my case) and port (49152).
So the question is - how to determine destination IP address of incoming multicast UPD packet.
Windows 7, Erlang 5.9/OTP R15B.
Thanks!