[zeromq-dev] strip topic in zmq message

Guo, Yanchao Yanchao.Guo at sac.com
Fri Jan 22 16:43:50 CET 2010

Hi Martin, the publish topic is part of received data buffer. Is there a function to strip it off? 


-----Original Message-----
From: Guo, Yanchao
Sent: Fri 1/22/2010 1:18 AM
To: Guo, Yanchao; zeromq-dev at lists.zeromq.org
Subject: RE: zmq poll failed
I think I found the cause:

in tcp_connecter.cpp, around line 286 when connect, 

    fd_t result = s;
    s = retired_fd;
    return result;

Why doing this? this affect all subsequent get_fd calls as that will return retired_fd. Is this only for TCP or for all protocols? 

-----Original Message-----
From: Guo, Yanchao
Sent: Fri 1/22/2010 1:11 AM
To: zeromq-dev at lists.zeromq.org
Subject: zmq poll failed
Hi Martin;

zmq::poll is not working with beta2.0. Below is my testing program and the zmq::poll is always returning -1. I did a bit debugging into the zeromq library, and found there is a check in zmq.cpp, around line 321:

 pollfds [npollfds].fd = app_thread->get_signaler ()->get_fd ();
        if (pollfds [npollfds].fd == zmq::retired_fd) {
            free (pollfds);
            errno = ENOTSUP;
            return -1;

I believe even for working zeromq socket, the fd is -1 (I printed the value from my test program). Any suggestion on how to fix this? 

#include <zmq.hpp>
#include "socket_base.hpp"
#include "app_thread.hpp"
#include "dispatcher.hpp"
#include "msg_content.hpp"
#include "platform.hpp"
#include "stdint.hpp"
#include "err.hpp"
#include "fd.hpp"

#include <iostream>
int main (int argc, char** argv)
        zmq::context_t ctx (1, 1);
        zmq::socket_t s0 (ctx, ZMQ_SUB);
        s0.connect ("tcp://");
        s0.setsockopt (ZMQ_SUBSCRIBE, "",0);

        zmq_pollitem_t p[1];
        p[0].socket = (void*)(s0);
        std::cout << "addr: " << &s0 << " cast to: " << p[0].socket << std::endl;
        zmq::socket_base_t *sb = (zmq::socket_base_t*) p[0].socket;
        int fd = sb->get_thread()->get_signaler()->get_fd();
        std::cout << "my fd: " << fd << " retired:" << zmq::retired_fd << std::endl; //both value are -1
        p[0].events = ZMQ_POLLIN;
        p[0].revents = 0;
        while (true){
                int rc = zmq::poll(p, 1);

                if (rc == -1){
                        std::cout << "poll error" << std::endl; //poll failed because of the above check 
                        for(int i = 0; i<1; i++){
                                for(short j = 0; j<p[i].revents; j++){
                                        zmq::message_t msg;
                                        s0.recv (&msg);
                                        std::string abc((char*)msg.data(), msg.size());
                                        std::cout << "socket: " << i << " event: " << j << " " << abc << std::endl;
        return 0;

DISCLAIMER: This e-mail message and any attachments are intended solely for the use of the individual or entity to which it is addressed and may contain information that is confidential or legally privileged. If you are not the intended recipient, you are hereby notified that any dissemination, distribution, copying or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and permanently delete this message and any attachments. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100122/4442a12d/attachment.htm>

More information about the zeromq-dev mailing list