[erlang-bugs] socket reuseaddr not functional on windows

Patrik Nyblom pan@REDACTED
Mon Oct 15 15:27:45 CEST 2012


Windows reuseaddr is dysfunctional and will reuse an address that is not 
in time_wait, i.e. it can steal sockets from other programs. There is a 
plethora of windows specific options to use instead, of which none 
emulates the correct behaviour without also expecting other programs to 
have used windows specific options, which they usually don't. I looked 
into it again some months ago, hoping that this was ancient history, but 
unfortunately Windows 7 still has this unexpected behaviour.

The only sensible thing, which allows for the best portability of code 
over platforms, is to ignore the option on Windows.

Cheers,
/Patrik
On 10/14/2012 05:54 AM, hume npx wrote:
> using reuseaddr option while do UDP socket  processing, it is not 
> functional. I searched the question on google, it seems that it's 
> caused by inet_drv.c line 5611, in fact win32 support reuseaddr, 
> should the following
>
> #ifdef __WIN32__
>     continue;  /* Bjorn says */
> #else
>
> part be commented?
>
> 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
>
>
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20121015/c318140b/attachment.htm>


More information about the erlang-bugs mailing list