Brian Buchanan <>
Thu Apr 28 07:40:15 CEST 2005

On Thu, 28 Apr 2005, Dietmar Schaefer wrote:

> If I understand it right
>  {reuseaddr, Boolean} as parameter for  gen_tcp:listen  allows local
> reuse of port numbers.
> So the error eaddrinuse should not occur ?
> Every time I try to reconnect to the server I get this error.

reuseaddr (or SO_REUSEADDR as it is translated to the kernel) only allows
reuse of port numbers that were recently used but not currently in use.
(They are not normally available for some period of time in order to
provide a strict implementation of the TCP specification).  If another
open socket has that port number, you won't be able to bind it.

I know that at least BSD-derived OSes support a SO_REUSEPORT option for
setsockopt() that enables multiple sockets to simultaneously listen on the
same address and port if all of them enable the option.  The Erlang inet
module doesn't appear to support this flag, however.

- Brian

More information about the erlang-questions mailing list