zeromq / clrzmq4

ZeroMQ C# namespace (.NET and mono, Windows, Linux and MacOSX, x86 and amd64)
GNU Lesser General Public License v3.0
241 stars 112 forks source link

Mapping of ZContextOption wrong #28

Closed gillima closed 9 years ago

gillima commented 9 years ago

The definition of the ZContextOption enum is different from the values in libzmq.

#define ZMQ_IO_THREADS  1
#define ZMQ_MAX_SOCKETS 2
public enum ZContextOption
{
    IO_THREADS,
    MAX_SOCKETS,
    IPV6
}

To reproduce use following code (where as 1024 is the default value for max sockets):

System.Diagnostics.Debug.Assert(zcontext.MaxSockets == 1024);
metadings commented 9 years ago

I wouldn't expect to have ctx.MaxSockets == 1024... And I don't see the hard difference, IO_THREADS == 1 and MAX_SOCKETS == 2

gillima commented 9 years ago

The problem is that C# enums start with 0, so IO_THREADS == 0. When you set zcontext.MaxSockets = 5, it will set IO_THREADS = 5 on the underlaying socket.

metadings commented 9 years ago

OH, I'm going to change that ;)

metadings commented 9 years ago

This is changed now.