[zeromq-dev] Vector transmission via REQ-REP. Am I missing something obvious?
Dorvin
dorvin at tlen.pl
Thu Apr 9 13:22:01 CEST 2015
sizeof() for containers doesn't work the way you'd like to. You should
use size() function of std::vector.
As you're using C++ i would recommend to change structs to objects (even
without methods if you don't need them), overload operators << and >>
for this class and do some simple serialization/deserialization or use
serialization library like Google Protobuf.
Cheers,
Jarek
W dniu 2015-04-09 o 12:53, James Chapman pisze:
> -- In case this appears twice, sent again this time from the list
> subscribed account --
>
> Hello list
>
> I could use some help... Using the REQ-REP model in C++ I'm trying to
> send a vector, but failing miserably and I can't work out why. Maybe
> this will never work? Maybe the idea of sending a vector is a bad and
> broken idea to start with and I should instead be trying to send a fixed
> size? But then if sending a vector is impossible, how do I send a
> variable amount of data? Should I just be using large enough buffers to
> allow for my largest expected data transfer? -This seems wasteful.
>
> Guidance on this matter would be greatly appreciated.
>
> I should add that failure is happening on the receiving end when trying
> to read the vector field.
>
> example (In this case TestMessage is a struct of what I want to send. If
> I include a vector<int> field in TestMessage it fails.)
>
> zmq::message_t * pZmqMsgOut =new zmq::message_t(sizeof(TestMessage));
> memcpy((void *)pZmqMsgOut->data(), pTestMsg,sizeof(*pTestMsg));
>
>
> Thanks in advance.
> James
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
More information about the zeromq-dev
mailing list