[zeromq-dev] zmq_msg_recv not blocking

Jeff Shanab jshanab at jfs-tech.com
Tue Nov 24 02:00:56 CET 2015


If I used zmq_send and zmq_recv it works.

If I use zmq_send on the server side and zmq_msg_recv on the client side,
it goes bonkers.

In this case the zmq_recv way is cleaner anyway. I will have to figure out
why the second combination didn't work when I have more time.

But in general, is it ok to mix the two?

On Mon, Nov 23, 2015 at 9:44 AM, Marcin Romaszewicz <marcin at brkt.com> wrote:

> That should be rc != -1. If you receive, say, 3 bytes, your error code
> will trigger. Those errno values could be from previous functions.
>
> On Mon, Nov 23, 2015 at 6:15 AM, Jeff Shanab <jshanab at jfs-tech.com> wrote:
>
>> The Guide has an assert (rc == 0) that of course exited the program.
>> I replaced that with the if (rc != 0) block  to get the error
>>
>> On Mon, Nov 23, 2015 at 8:31 AM, KIU Shueng Chuan <nixchuan at gmail.com>
>> wrote:
>>
>>> Note that zmq_msg_recv() returns >= 0 on success.
>>> On 23 Nov 2015 19:54, "Jeff Shanab" <jshanab at jfs-tech.com> wrote:
>>>
>>>> I have used a previous version of zmq with google protocol buffers a
>>>> few years ago but am trying a simpler project with the newest zmq and have
>>>> run into a problem.
>>>>
>>>> Imagine the weather server and client converted to the multipart
>>>> message code in the guide. But when I call zmq_msg_recv(&part,
>>>> subscriber,0), it does not block!
>>>>
>>>> do {
>>>>         /* Create an empty ØMQ message to hold the message part */
>>>>         zmq_msg_t part;
>>>>         int rc = zmq_msg_init (&part);
>>>>         assert (rc == 0);
>>>>         /* Block until a message is available to be received from
>>>> socket */
>>>>         rc = zmq_msg_recv (&part, subscriber,0);
>>>>
>>>>         if (rc != 0)
>>>>         {
>>>>             std::cout << "First msg Recv error :" << zmq_errno() <<
>>>> zmq_strerror (zmq_errno()) << std::endl;
>>>>
>>>> boost::this_thread::sleep(boost::posix_time::milliseconds(250));
>>>>             continue;
>>>>         };
>>>>
>>>>         rc = zmq_getsockopt (subscriber, ZMQ_RCVMORE, &more,
>>>> &more_size);
>>>>         assert (rc == 0);
>>>>
>>>>         ....
>>>>
>>>> With this code, I get
>>>>
>>>> First msg Recv error :35Resource temporarily unavailable
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed out
>>>> First msg Recv error :60Operation timed o ...
>>>>
>>>> This is on OSX. I am going to try windows and linux after work tonight.
>>>>
>>>> Are there any known issues with 4.1.3, zmq_msg_recv and OSX ?
>>>>
>>>> _______________________________________________
>>>> zeromq-dev mailing list
>>>> zeromq-dev at lists.zeromq.org
>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>
>>>>
>>> _______________________________________________
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>
>>>
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20151123/bace698f/attachment.htm>


More information about the zeromq-dev mailing list