[zeromq-dev] 0MQ 3.0 - API improvements
Martin Sustrik
sustrik at 250bpm.com
Fri Apr 8 08:19:35 CEST 2011
Hi Pieter,
> There's an aspect of the current API which is unfortunate, and causes
> errors that could be avoided, and that's the use of 'void *' for
> contexts and sockets.
>
> This basically prevents the C/C++ compiler from type checking in many cases.
>
> I'd suggest that zmq_context_t * and zmq_socket_t *, pointing to
> opaque types, would be better and easier to work with.
The use case being accidentally passing context handle to a socket, right?
I don't know. In the ideal, fully POSIX-compliant world, the sockets
would be identified by ints, which are not type-safe either.
Maybe a cleaner way would be to put few hard-wired bytes at the
beginning of the socket structure and check those in each function,
returning EFAULT if it does not match.
Anyone any thoughts on the topic?
Martin
More information about the zeromq-dev
mailing list