[zeromq-dev] Using polling with zactor in C
Pieter Hintjens
ph at imatix.com
Sun Dec 13 08:37:06 CET 2015
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 <robert at layer2.com> 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 at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
More information about the zeromq-dev
mailing list