broadcast

Joe Armstrong joe@REDACTED
Wed Jul 3 15:39:46 CEST 2002


I have several machines on a LAN

How do I set up a low-level broadcast system.

I can find the broadcast address with
 
    {ok, [{broadaddr, Ip}]} = inet:ifget("eth0", [broadaddr]),

But then what?

    How do I send to the broadcast address and what port do I use?

This didn't work:

	{ok, S} = gen_udp:open(5010),
        gen_udp:send(S, Ip, 6000, Str)

open works but send fails with {error, eacess}

I'd thought that this would send a broadcast message to port 6000
and that all machines on the LAN that listen to broadcasts
would see this message. 

The listener I guess is something like

   {ok, S} = gen_udp:open(6000),
   loop(S).

loop(Socket) ->
    receive
	{udp, Socket, Host, Port} ->
	    ...
	    loop(Socket)
    end.

And here I imagined that Port would be 5010 and Host the machine sending the 
packet.

  Is this how  to do set up a  listener and do a broadcast?  Or have I
totally misunderstood.

Any ideas what is going wrong here????

Thanks

/Joe

 




More information about the erlang-questions mailing list