Re: [zeromq-dev] zmq_poll not working on Windows
Hi Martin, I think it's ok. I'm using the cpp wrapper, so naturally I should have used the void* returned by zmq_socket instead of the pointer of the zmq::socket_t object. To make it more sane for users of the cpp wrapper, we could add a function like this to the cpp wrapper: inline void InitPollItem(zmq_pollitem_t& item, zmq::socket_t* pSocket, short sEvents, int iFD = 0, short sREvents = 0) { if (pSocket) item.socket = *pSocket; else item.socket = NULL; item.fd = iFD; item.events = sEvents; item.revents = sREvents; } Cheers, Marko - Ursprüngliche Nachricht - Von: Martin Sustrik Gesendet: 04.10.11 20:05 Uhr An: ZeroMQ development list Betreff: Re: [zeromq-dev] zmq_poll not working on Windows On 10/04/2011 05:49 PM, marko.dieckm...@gmx.de wrote: > It's a bit confusing, though, because the struct has a void* in it. So I > thought he wants the pointer. ;) Yes. This is not the first time someone was confused. Let's fix it at least in the new version of cppzmq. Any suggestions for a more sane syntax? Martin ___ 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] zmq_poll not working on Windows
On 10/04/2011 05:49 PM, marko.dieckm...@gmx.de wrote: > It's a bit confusing, though, because the struct has a void* in it. So I > thought he wants the pointer. ;) Yes. This is not the first time someone was confused. Let's fix it at least in the new version of cppzmq. Any suggestions for a more sane syntax? Martin ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] zmq_poll not working on Windows
Hi Mikko, Thanks for the quick response! That was it indeed. It's working now. It's a bit confusing, though, because the struct has a void* in it. So I thought he wants the pointer. ;) I'll look at the samples more closely next time. Cheers, Marko - Ursprüngliche Nachricht - Von: Mikko Koppanen Gesendet: 04.10.11 17:30 Uhr An: ZeroMQ development list Betreff: Re: [zeromq-dev] zmq_poll not working on Windows On Tue, Oct 4, 2011 at 4:12 PM, wrote: > Hello everyone, > > I tried to make zmq_poll work in my zmq 2.1.9 sample application for Windows > 7 (x64), but without success. > > For this test I have a PUB/SUB setup between 2 threads. > > // open INPROC socket to communicate with main thread > m_pInprocSocket = new zmq::socket_t(m_pZMQContext, ZMQ_SUB); > m_pInprocSocket->connect("inproc://thread_com"); > m_pInprocSocket->setsockopt(ZMQ_SUBSCRIBE, "", 0); > > Then in thread that opened the SUB socket I want to poll, like: > > zmq_pollitem_t pi[] = { m_pInprocSocket, 0, ZMQ_POLLIN, 0 }; Hi, if you look at the poll examples carefully (http://zguide.zeromq.org/cpp:mspoller) you need to pass the actual object to the poll_item_t rather than a pointer to it. Try: zmq_pollitem_t pi[] = { *m_pInprocSocket, 0, ZMQ_POLLIN, 0 }; thanks, mikko ___ 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] zmq_poll not working on Windows
On Tue, Oct 4, 2011 at 4:12 PM, wrote: > Hello everyone, > > I tried to make zmq_poll work in my zmq 2.1.9 sample application for Windows > 7 (x64), but without success. > > For this test I have a PUB/SUB setup between 2 threads. > > // open INPROC socket to communicate with main thread > m_pInprocSocket = new zmq::socket_t(m_pZMQContext, ZMQ_SUB); > m_pInprocSocket->connect("inproc://thread_com"); > m_pInprocSocket->setsockopt(ZMQ_SUBSCRIBE, "", 0); > > Then in thread that opened the SUB socket I want to poll, like: > > zmq_pollitem_t pi[] = { m_pInprocSocket, 0, ZMQ_POLLIN, 0 }; Hi, if you look at the poll examples carefully (http://zguide.zeromq.org/cpp:mspoller) you need to pass the actual object to the poll_item_t rather than a pointer to it. Try: zmq_pollitem_t pi[] = { *m_pInprocSocket, 0, ZMQ_POLLIN, 0 }; thanks, mikko ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
[zeromq-dev] zmq_poll not working on Windows
Hello everyone, I tried to make zmq_poll work in my zmq 2.1.9 sample application for Windows 7 (x64), but without success. For this test I have a PUB/SUB setup between 2 threads. // open INPROC socket to communicate with main thread m_pInprocSocket = new zmq::socket_t(m_pZMQContext, ZMQ_SUB); m_pInprocSocket->connect("inproc://thread_com"); m_pInprocSocket->setsockopt(ZMQ_SUBSCRIBE, "", 0); Then in thread that opened the SUB socket I want to poll, like: zmq_pollitem_t pi[] = { m_pInprocSocket, 0, ZMQ_POLLIN, 0 }; zmq_poll(pi, 1, -1); // check INPROC socket if (pi[0].revents & ZMQ_POLLIN) { ... etc } Now, with zmq_poll the ZMQ_POLLIN event is never triggered, but I receive the messages, when I just use recv without polling. After stepping into zmq_poll, it seems to be that this is the line where it exits: // Build the fd_sets for passing to select (). for (int i = 0; i != nitems_; i++) { // If the poll item is a 0MQ socket we are interested in input on the // notification file descriptor retrieved by the ZMQ_FD socket option. if (items_ [i].socket) { size_t zmq_fd_size = sizeof (zmq::fd_t); zmq::fd_t notify_fd; if (zmq_getsockopt (items_ [i].socket, ZMQ_FD, ¬ify_fd, &zmq_fd_size) == -1) return -1; Does anybody have a tip what this could be? Cheers, Marko ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev