Steven Robertson
não lida,14/09/2010, 16:47:0414/09/10Inicie sessão para responder ao autor
Inicie sessão para encaminhar
Não tem autorização para eliminar mensagens neste grupo.
Inicie sessão para denunciar a mensagem
Mostrar mensagem original
Os endereços de email deste grupo são anónimos ou precisará da autorização para ver os endereços de email dos membros para conseguir ver a mensagem original.
para 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.