[zeromq-dev] Checking for errors on zmq_poll: is it correct?

Chernyshev Vyacheslav astellar at ro.ru
Thu Aug 16 23:00:35 CEST 2012


17.08.12, 0:51, Claudio Carbone wrote:
> Zerrno = zmq_poll(...);
> If(zerrno != 0)
> Printf("%s",zmq-strerror(zerrno);
zmq_poll returns -1 if error has happened, 0 if no events were triggered 
during waiting in zmq_poll, and some integer value N (where N is > 0) to 
indicate number of zmq_pollitem_t items where some event has happened.

You register only one pollitem, so possible return values are -1, 0, 1. 
If you want to check for error, you must compare return code with -1. 
Something like that:
     int const res = zmq_poll(...);
     if (-1 == res)
         printf("%s", zmq_strerror(errno));




More information about the zeromq-dev mailing list