Hi Luke Thanks for your advice and i will have a try.
On Fri, Aug 9, 2013 at 9:57 AM, Lucas Hope <[email protected]> wrote: > Hi again, > > Sorry, it is important that the first struct member is a char array (char > arr[10]), and not a char pointer (char *ptr), as arr gets encoded directly > as part of the struct, but the ptr does not. > > Luke > > > On Fri, Aug 9, 2013 at 11:54 AM, Lucas Hope <[email protected]>wrote: > >> Hi there, >> >> I don't know 100%. Subscriptions are prefix based. The way structs work >> in C is that they are packed according to member order. If your first >> struct member was a cstring (char *, null-terminated), then the >> subscription prefix should match that okay. I'm not sure how C++ strings >> are represented. It might still work if they hold the char buffer at the >> front. >> >> I hope that helps. I'm not that qualified to answer, really. >> >> Cheers, >> >> Luke >> >> >> On Fri, Aug 9, 2013 at 11:06 AM, Roy Liu <[email protected]> wrote: >> >>> Anyone knows? >>> I can not find documents about the filter format according to different >>> data type. >>> >>> >>> On Thu, Aug 8, 2013 at 10:30 PM, <[email protected]> wrote: >>> >>>> 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 >>> >>> >> >> >> -- >> --------------------------------------------------- >> Dr Lucas Hope - lucas.r.hope@skype >> Machine Learning and Software Engineering Consultant >> Melbourne, Australia >> > > > > -- > --------------------------------------------------- > Dr Lucas Hope - lucas.r.hope@skype > Machine Learning and Software Engineering Consultant > Melbourne, Australia > > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > >
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
