Joe Armstrong <>
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(Socket) ->
	{udp, Socket, Host, Port} ->

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

  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????




More information about the erlang-questions mailing list