[zeromq-dev] Problem with multiple sockets under Windows: Address already in use

Seref Arikan serefarikan at kurumsalteknoloji.com
Tue Jun 21 12:40:48 CEST 2011

It looks as if it is not only about the number of sockets open at a
time, but also about the closing of sockets. If I run the example loop
with 100 iterations, it works, but if I repeat the 100 iterations loop
a few times, it crashes. I found out that I have to wait for some
time, before the code can work again. So Windows does not only seem to
limit the number of sockets, but it also appears to not to make them
available as soon as the socket is closed. I could introduce an upper
limit for open sockets in my code, or increase the upper limit using
Windows' configuration, but as long as a socket that is closed does
not become available instantly, this would be a serious issue.
Should  this also be considered a Windows issue? (slowly
released/freed sockets)

Ps: I've tested it again, if I wait for a minute or two, the 100
iteration loop works, then fills up whatever mechanism Windows is
using, and I've to wait again...

On Mon, Jun 20, 2011 at 3:58 PM, Steven McCoy <steven.mccoy at miru.hk> wrote:
> On 20 June 2011 10:12, Seref Arikan <serefarikan at kurumsalteknoloji.com>
> wrote:
>> Thanks Martin,
>> With the following modified code  below (assuming I'm doing the error
>> handling right), I get no errors at all  I just get the "Assertion
>> failed: Address already in use (..\..\..\src\mailbox.cpp:305)" output
>> in the command prompt.
> It would appear WinSock does not provide a return code for socket exhaustion
> from bind/connect, this is a delayed error from bind.  On Windows XP the
> default limit appears to be 3,975 sockets between 1,025 and 5,000:
> http://msdn.microsoft.com/en-us/library/ms737550(v=vs.85).aspx
>> HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
>> The MaxUserPort registry value sets the value to use for the maximum value
>> of the dynamic client port range. You must restart the computer for this
>> setting to take effect.
> Ideally along with out-of-memory errors ZeroMQ should be handling socket and
> file handle exhaustion.
> --
> Steve-o
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

More information about the zeromq-dev mailing list