[zeromq-dev] JZMQ non-blocking recvByteBuffer

Trevor Bernard trevor.bernard at gmail.com
Tue Jul 1 23:38:53 CEST 2014


This is likely a typo -- I'd be happy to merge a pull request if you
would be so kind to submit a patch.

On Tue, Jul 1, 2014 at 6:27 PM, Petr Postulka <ppostulka at gmail.com> wrote:
> Hi all,
>
> I have a question regarding non-blocking recvByteBuffer call in JZMQ -
> whenever there are no data to receive the call throws an exception and I'm
> not sure whether this is the proper way how it should be implemented. Maybe
> I'm missing something here, but when I checked the corresponding C++ code in
> Socket.cpp class I can see the following block of code in recvByteBuffer
> method implementation:
>
>     int read = zmq_recv(sock, buf + pos, rem, flags);
>     if (read > 0) {
>         read = read > rem ? rem : read;
>         env->CallObjectMethod(buffer, setPositionMID, read + pos);
>         return read;
>     }
>     else if(read == -1) {
>         int err = zmq_errno();
>         if(err == EAGAIN) {
>             raise_exception (env, err);
>             return 0;
>         }
>     }
>     return read;
>
> If I understand it correctly, shouldn't there be  if(err != EAGAIN) then
> raise_exception? Because right now it is throwing exception only when there
> are no data to receive, which is making non-blocking call basically unusable
> because throwing and catching the exception is very costly operation. At the
> same time other errors, which are in contrast to EAGAIN much more important
> do not throw the exception at all.
>
> Please let me know whether my assumption is correct or not.
>
> Thank you and kind regards,
>
> Petr
>
> _______________________________________________
> 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