[erlang-questions] Multicast UDP sending question

Sam Bobroff samb-bulk@REDACTED
Fri Nov 20 17:21:11 CET 2009


Valentin Micic wrote:
> Don't know what to tell you -- I've tried similar thing from Windoze and got
> what I've expected:
>
> Started two shells with following result:
>
> FIRST:
>
> Erlang (BEAM) emulator version 5.5.4 [async-threads:0]
>
> Eshell V5.5.4  (abort with ^G)
> (vhlr@REDACTED)1> gen_udp:open( 9999, [{reuseaddr, true}] ).
> {ok,#Port<0.97>}
> (vhlr@REDACTED)2>
>
> SECOND:
>
> Erlang (BEAM) emulator version 5.5.4 [async-threads:0]
>
> Eshell V5.5.4  (abort with ^G)
> (uscript@REDACTED)1> gen_udp:open( 9999, [{reuseaddr, true}] ).
> {error,eaddrinuse}
> (uscript@REDACTED)2>
>
>
> Hope this is helpful too.
>
> V/
That IS quite interesting! I found some documentation on MSDN that 
seemed to indicate that SO_REUSEADDR was available under Windows, and 
that it actually did pretty much the same thing as Linux... So if that 
were the case then Erlang must be doing something differently. I grepped 
around in the source code and look what I found in "inet_setopts" in 
"inet_drv.c":

    case INET_OPT_REUSEADDR:
#ifdef __WIN32__
        continue;  /* Bjorn says */
#else
        type = SO_REUSEADDR;
        DEBUGF(("inet_set_opts(%ld): s=%d, SO_REUSEADDR=%d\r\n",
            (long)desc->port, desc->s,ival));
        break;
#endif

(From R13B02)

So! reuseaddr does *nothing* in Erlang under Windows, but on other OSes 
it does! That certainly explains our different results. Perhaps the 
Erlang documentation for gen_udp should mention that this flag is 
unimplemented on Windows?

Sam.


More information about the erlang-questions mailing list