Hi, everyone

On PUB side: wd is struct type message and I send it to the subscriber.
typedef struct tag_StructData
{
        string name;
}StructData;

StructData wd;
//  Prepare our context and publisher
zmq::context_t context (1);
zmq::socket_t publisher (context, ZMQ_PUB);
int msgSize = sizeof(wd);
zmq::message_t message(msgSize);
memcpy ((void *) message.data(), &wd, msgSize);
publisher.send(message);


On SUB side:
// Receive Everything
        subscriber.setsockopt(ZMQ_SUBSCRIBE, NULL, 0); 
// How to set a filter to receive the struct message with the specified name, 
for example "ABC".
 
        //string msg;
        StructData *msg;
        while(true){
                zmq::message_t m;
                subscriber.recv(&m);
                msg = (StructData *)m.data();
                cout << msg->Symbol << endl;
        }


Thanks.

--
Best Regards,
Roy Liu

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to