[erlang-questions] clarify: SO_REUSEADDR under darwin?

Valentin Micic <>
Fri Nov 9 18:43:39 CET 2007


The way this worked with C/C++ was to first bind to an UDP port, using 
"normal" interface (ip address) and then add memebership via setsockopt 
system call. I think that something similar (undocumented as it might be) 
should be applicable for ERLANG too. Combining it wiht gen_udp:open, may 
create a wrong impression... I mean, you are actually receiving the traffic 
via the "real" interface after all.

V.

----- Original Message ----- 
From: "Serge Aleynikov" <>
To: "Per Hedeland" <>
Cc: <>
Sent: Friday, November 09, 2007 3:00 PM
Subject: Re: [erlang-questions] clarify: SO_REUSEADDR under darwin?


> Per Hedeland wrote:
>> Actually no, it says that for multicast *addresses*, it is (there's no
>> such thing as a multicast port:-). And this seems to be true on all of
>> Linux, Darwin, and FreeBSD. I.e. you need to pass in an actual multicast
>> address to bind to, instead of letting it default to the wildcard
>> address - then reuseaddr is enough:
>>
>> mars 9> uname -sr
>> FreeBSD 6.2-STABLE-200709
>> mars 10> erl
>> Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [hipe]
>>
>> Eshell V5.5.5  (abort with ^G)
>> 1> Port=4545.
>> 4545
>> 2> gen_udp:open(Port, [{reuseaddr, true}, {ip, {224,0,1,1}}]).
>> {ok,#Port<0.96>}
>> 3> gen_udp:open(Port, [{reuseaddr, true}, {ip, {224,0,1,1}}]).
>> {ok,#Port<0.97>}
>> 4> gen_udp:open(Port, [{reuseaddr, true}, {ip, {224,0,1,1}}]).
>> {ok,#Port<0.98>}
>
> Is this the "right" way of joining a multicast group though?  I've been
> using the "undocumented" add_membership inet option to accomplish that
> (though haven't tried it on anything other than Win, Linux, Solaris):
>
> gen_udp:open(Port, [{reuseaddr, true}, {add_membership, {Addr,
> Interface}}]).
>
> I haven't checked the inet_drv, but does it actually check if in the
> {ip, Addr} option Addr refers to a multicast range and sets the
> IP_ADD_MEMBERSHIP option?
>
> Serge
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list