4

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!

3DFace
  • 86
  • 6
  • You might consider asking this on erlang-questions if you don't get an answer here. – Peer Stritzinger Feb 13 '12 at 13:09
  • Read this: http://stackoverflow.com/questions/1746257/how-to-send-multicast-messages-and-reuse-a-port-in-erlang – Ricardo Feb 27 '12 at 19:46
  • Ricardo, at first I thought you post a link to point me to an answer. But now I guess you wanted me to give you an advise. Unfortunately, I cant help you. – 3DFace Mar 16 '12 at 22:54

1 Answers1

0

This should retrieve the destination IP from received UDP data:

{udp, Socket, IP, PortNo, Packet},
{ok, {Address, Port}} = inet:sockname(Socket),

Address will contain tuple like {239,0,1,3}.

Ivan Blinkov
  • 2,466
  • 15
  • 17
  • Unfortunately it does not. Address contains my real ip address (194.x.x.88), not a multicast group address. – 3DFace May 30 '12 at 10:19