Re: [zeromq-dev] Using polling with zactor in C
Hi Robert, You are mixing abstractions here. The zmq_poll layer takes zmq sockets, which are void pointers. The CZMQ zsock_t class is a higher-level socket object. If you look at the CZMQ examples you'll see we use zloop or zpoller (simpler, and recommended) to work on zsock_t objects. -Pieter On Sat, Dec 12, 2015 at 9:28 PM, Robert Johnston wrote: > Hi, > > > > I had an application using 0mq V3.x that used zthread_fork to create workers > with sockets to the outside world. The threads used zmq_poll to catch events > from the main application and the sockets. > > > > Now I have updated to V4.2.0 and trying to re-do the application the zactor > way. And not having much luck with polling. > > > > As a simple test, I used the echo test with polling added to echo_actor > (partially shown below). Nothing happens. If I comment out the “if > (items[0] …” line, the test runs. > > > > What am I missing? Does zactor require a different polling method? Can you > point me to an example? > > > > Any and all comments, suggestions, praise, or blame gratefully accepted. > > > > Thanks > > > > Robert > > > > // > -- > > // Actor > > // must call zsock_signal (pipe) when initialized > > // must listen to pipe and exit on $TERM command > > > > void > > echo_actor (zsock_t *pipe, void *args) > > { > >zmq_pollitem_t items[] = > >{ > > {pipe, 0, ZMQ_POLLIN, 0} > >}; > > > >// Do some initialization > >assert (streq ((char *) args, "Hello, World")); > >zsock_signal (pipe, 0); > > > >bool terminated = false; > >while (!terminated) { > > zmq_poll (items, 1, 0); > > > > if (items[0].revents & ZMQ_POLLIN) > > { > >Etc. > > > ___ > zeromq-dev mailing list > zeromq-dev@lists.zeromq.org > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] 64bit Issue discovered with zmq_getsockopt(..., ZMQ_RCVMORE, ...
It took a bit of time to find out the guide led me down the wrong path. :-( If it doesn't work, it really shouldn't be the suggested code in the guide. On Sat, Dec 12, 2015 at 4:57 PM, KIU Shueng Chuan wrote: > The type of that socket option was changed to "int" since version 3.2.x > > Rather than extracting the more flag using getsockopt, you can also do: > > int more = zmq_msg_more (&part); > On 13 Dec 2015 03:01, "Jeff Shanab" wrote: > >> Using ZMQ 4.0.4 on windows 64bit in Visual studio with a simple REQ-REP >> with multipart messages. >> >> All examples and guide show code like >> >> int64_t more; >> size_t more_size = sizeof more; >> 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, socket, 0); >> assert (rc != -1); >> /* Determine if more message parts are to follow */ >> rc = zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size); >> assert (rc == 0); >> zmq_msg_close (&part); } while (more); >> >> >> I found that the value of more is a ridiculously large negative integer >> and fails to detect the last frame unless I initialize it to zero. >> >> (note Debug in GCC zeros memory, Visual Studio does not.) >> >> Inspection of the value in hex may reveal a 64 bit porting problem, >> >> The values is 0x >> >> Which is setting it to a int const without the ull specifier >> >> Anyway I change "int64_t more;" to "int64_t more = 0;" and operation is >> restored. >> >> >> >> >> >> >> ___ >> zeromq-dev mailing list >> zeromq-dev@lists.zeromq.org >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev >> >> > ___ > zeromq-dev mailing list > zeromq-dev@lists.zeromq.org > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > > ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] 64bit Issue discovered with zmq_getsockopt(..., ZMQ_RCVMORE, ...
The type of that socket option was changed to "int" since version 3.2.x Rather than extracting the more flag using getsockopt, you can also do: int more = zmq_msg_more (&part); On 13 Dec 2015 03:01, "Jeff Shanab" wrote: > Using ZMQ 4.0.4 on windows 64bit in Visual studio with a simple REQ-REP > with multipart messages. > > All examples and guide show code like > > int64_t more; > size_t more_size = sizeof more; > 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, socket, 0); > assert (rc != -1); > /* Determine if more message parts are to follow */ > rc = zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size); > assert (rc == 0); > zmq_msg_close (&part); } while (more); > > > I found that the value of more is a ridiculously large negative integer > and fails to detect the last frame unless I initialize it to zero. > > (note Debug in GCC zeros memory, Visual Studio does not.) > > Inspection of the value in hex may reveal a 64 bit porting problem, > > The values is 0x > > Which is setting it to a int const without the ull specifier > > Anyway I change "int64_t more;" to "int64_t more = 0;" and operation is > restored. > > > > > > > ___ > zeromq-dev mailing list > zeromq-dev@lists.zeromq.org > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > > ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
[zeromq-dev] Using polling with zactor in C
Hi, I had an application using 0mq V3.x that used zthread_fork to create workers with sockets to the outside world. The threads used zmq_poll to catch events from the main application and the sockets. Now I have updated to V4.2.0 and trying to re-do the application the zactor way. And not having much luck with polling. As a simple test, I used the echo test with polling added to echo_actor (partially shown below). Nothing happens. If I comment out the "if (items[0] ." line, the test runs. What am I missing? Does zactor require a different polling method? Can you point me to an example? Any and all comments, suggestions, praise, or blame gratefully accepted. Thanks Robert // -- // Actor // must call zsock_signal (pipe) when initialized // must listen to pipe and exit on $TERM command void echo_actor (zsock_t *pipe, void *args) { zmq_pollitem_t items[] = { {pipe, 0, ZMQ_POLLIN, 0} }; // Do some initialization assert (streq ((char *) args, "Hello, World")); zsock_signal (pipe, 0); bool terminated = false; while (!terminated) { zmq_poll (items, 1, 0); if (items[0].revents & ZMQ_POLLIN) { Etc. ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
[zeromq-dev] 64bit Issue discovered with zmq_getsockopt(..., ZMQ_RCVMORE, ...
Using ZMQ 4.0.4 on windows 64bit in Visual studio with a simple REQ-REP with multipart messages. All examples and guide show code like int64_t more; size_t more_size = sizeof more; 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, socket, 0); assert (rc != -1); /* Determine if more message parts are to follow */ rc = zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size); assert (rc == 0); zmq_msg_close (&part); } while (more); I found that the value of more is a ridiculously large negative integer and fails to detect the last frame unless I initialize it to zero. (note Debug in GCC zeros memory, Visual Studio does not.) Inspection of the value in hex may reveal a 64 bit porting problem, The values is 0x Which is setting it to a int const without the ull specifier Anyway I change "int64_t more;" to "int64_t more = 0;" and operation is restored. ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] ZeroMQ hackathon/workshop (Brussels, 27/1-29/1 2016)
FYI, We have two possible locations: * https://hackerspace.be/welcome/index.html Hackerspace Brussels, rue de Manchester/Manchesterstraat 17, 1080 Molenbeek, Brussels, Belgium * https://www.flickr.com/photos/alleedukaai/sets Allée Du Kaai, Avenue Du Port 49 – 55 Bruxelles -Pieter On Sun, Nov 15, 2015 at 2:14 PM, Brian Knox wrote: > I'll be a little late the first day - if all goes well I arrive in Brussels > at 7:30am that Wednesday morning. Can't wait to see everyone who is going! > > Brian > > On Sun, Nov 15, 2015 at 1:57 AM, Trevor Bernard > wrote: >> >> I'm very much looking forward to participating at FOSDEM and the >> hackathon before it. I hope to see you people there. >> >> On Sun, Nov 15, 2015 at 2:50 AM, Pieter Hintjens wrote: >> > Hi all, >> > >> > On the days before FOSDEM (the largest free and open source >> > developers' meeting in Europe), we're running a 3-day hackathon and >> > workshop for the ZeroMQ community. >> > >> > This event is free and possibly the best ZeroMQ training you can get >> > anywhere on the planet. Space is limited to 20 participants. Please >> > register on http://zeromq.org/event:zeromq-meetup-brussels. >> > >> > -Pieter Hintjens >> > ___ >> > zeromq-dev mailing list >> > zeromq-dev@lists.zeromq.org >> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev >> ___ >> zeromq-dev mailing list >> zeromq-dev@lists.zeromq.org >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev > > > > ___ > zeromq-dev mailing list > zeromq-dev@lists.zeromq.org > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev