[erlang-questions] clarify: SO_REUSEADDR under darwin?

Per Hedeland per@REDACTED
Fri Nov 9 08:35:26 CET 2007

Paul Mineiro <paul-trapexit@REDACTED> wrote:

>If somebody has a better way of going about this, I'd love to hear it.

>> However this link says that for multicast ports, SO_REUSEADDR is the same

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.
2> gen_udp:open(Port, [{reuseaddr, true}, {ip, {224,0,1,1}}]).
3> gen_udp:open(Port, [{reuseaddr, true}, {ip, {224,0,1,1}}]).
4> gen_udp:open(Port, [{reuseaddr, true}, {ip, {224,0,1,1}}]).

The Linux behaviour seems like a bug to me.

--Per Hedeland

More information about the erlang-questions mailing list