[zeromq-dev] zeromq, abort(), and high reliability environments

Goswin von Brederlow goswin-v-b at web.de
Thu Aug 14 12:25:48 CEST 2014

On Wed, Aug 13, 2014 at 08:37:36AM +0200, Pieter Hintjens wrote:
> In our APIs we've stripped down error reporting to a minimum. libzmq
> with its POSIX tendencies still relies IMO far too heavily on subtle
> error returns (errno == EAGAIN vs. errno == EINVAL?).

In higher level language bindings that can be fixed. For example in
ocaml you would have

val recv : ?(wait=true) -> socket -> msg option

Recv is a function taking an optional argument "wait" [must be before
socket due to language constraints] and a socket and returns an
optional message. Meaning it may return "None" or "Some message". An
error of EAGAIN or EINTR would return None (no message was received)
while EINVAL or other true errors would throw an exception.

> CZMQ is much
> cleaner: a method works, or fails if there's a recoverable error, or
> asserts if there's an unrecoverable error.

The key point there is *recoverable error*. An invalid argument to a
function is clearly recoverable. The function simply does nothing and
returns EINVAL.

So are you contradicting yourself here? EINVAL is bad but CZMQ is
better because it returns EINVAL? :)


More information about the zeromq-dev mailing list