Steven Robertson
unread,Sep 14, 2010, 4:47:04 PM9/14/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to playdar
The Programming Erlang book has an example of UDP broadcast with a
different code example so I've been trying this in the hope of having
Playdar on Windows behave more as expected. Some success, but not
using IGMP and using 255.255.255.255 as the broadcast address and
using different port for sending and receiving messages. This may not
be appropriate. I'd really like to know. In my test it does work
passing messages between Erlang shell on a Windows 7 and Arch Linux
set-up.
Here's the code if anyone is able to advise:
-module(broadcast).
-compile(export_all).
-define(SEND_FROM_PORT, 60212).
-define(LISTEN_TO_PORT, 60210).
-define(BROADCAST_ADDR, {255,255,255,255}).
send(IoList) ->
{ok, S} = gen_udp:open(?SEND_FROM_PORT, [{broadcast, true}]),
gen_udp:send(S, ?BROADCAST_ADDR, ?LISTEN_TO_PORT, IoList),
gen_udp:close(S).
listen() ->
{ok, _} = gen_udp:open(?LISTEN_TO_PORT),
loop().
loop() ->
receive
Any ->
io:format("received:~p~n", [Any]),
loop()
end.