|
Joined: 24 Jun 2008
Posts: 1
|
Hello
Absolute Erlang newbie here, trying to do a UDP multicast receive on Windows as a useful/interesting test case for my purposes.
Version is: Erlang (BEAM) emulator version 5.6.3 [smp:2] [async-threads:0]
Below is my code - What I am trying to do is listen on "address" 224.0.66.66 "port"6666.
My computer's regular IP address is 192.168.6.49 on our internal network.
The code "runs" ok, but never seems to receive anything, I always get the "huh" output, and I know from other handlers that there are all sorts of packets flying by on this multicast address.
Help?!
Abject and humble apologies if this is the wrong forum.
Scott
Code:
-module(listen).
-export([init/0, loop/1]).
loop(Socket) ->
io:format("in-loop~n"),
receive
{udp, Socket, Host, Port, Bin} ->
io:format("host",Host),
io:format("Port: ", Port),
io:format("BinSize: ", size(Bin)),
loop(Socket);
{udp, _ } ->
io:format("got one")
after 2000 ->
io:format("huh?~n")
end,
gen_udp:close(Socket).
init() ->
{ok, Socket} = gen_udp:open(6666, [binary,
{reuseaddr,true},
{multicast_loop,true},
{ip,{192,168,6,49}},
{add_membership,{{224,0,66,66},{192,168,6,49}}}]),
loop(Socket).
|
|
|