Thanks Ju. Actually, I was confused a litle. I saw the C API, which uses zmsg_popmsg. However, since I am using C++, I tried to search for equivalent C++ API but I couldn't.
This is why I mentioned twice that the message consists of ZFrame and ZFrame is initialized with the byte array. Hence I was expecting that first I need to use some kind of pop msg and then get the byte array. I really appreciate your help. Thanks again. - Ravi On Saturday, 25 November 2017 12:02 AM, Juergen Gnoss <[email protected]> wrote: Just as a pathfinder I don't know nothing about the C++ bindings of zmq and how it is implemented. In C bindings you need to "pop" each part of the message in a variable of your choice, then you can handle that variable as you do normal in your language. In C after receiving the message from your socket, you do : int msgsize =zmsg_size(receivedMessage); byte *msgContent =zmsg_popmsg(receivedMessage); then for (int x = 0; i < msgsize; i++) { doSomeThingWith(msgContent[i]); } Ju ________________________________ From: zeromq-dev <[email protected]> on behalf of Ravi Joshi via zeromq-dev <[email protected]> Sent: Friday, November 24, 2017 12:39 AM To: ZeroMQ development list Cc: Ravi Joshi; Mykola Ostrovskyy Subject: Re: [zeromq-dev] How to receive byte array in ZeroMQ C++ Dear Mykola, Thank you very much. The message is defined in C# as follows: var message = new ZMessage { new ZFrame(myByteArray) }; publisher.Send(message); I want to get the byte array in C++. May I use something like following: zmq::message_t msg; int rc = zmq_socket.recv(&msg); if (rc) { unsigned char bytearray[] = msg.data(); } Please check out following Pastebin links, to see publisher and subscriber code: (1) https://pastebin.com/PJ7f2TJ5 (2) https://pastebin.com/JKf0cZjh - Thanks Ravi On Friday, 24 November 2017 1:35 AM, Mykola Ostrovskyy via zeromq-dev <[email protected]> wrote: Hello Ravi, If that's just a raw byte array, msg.data<uint8_t>() should to the trick. For example: for (size_t i = 0; i < msg.size(); ++i) { printf("%02X ", msg.data<uint8_t>()[i]); } Regards, Mykola 2017-11-23 14:52 GMT+02:00 Ravi Joshi via zeromq-dev <[email protected]>: Hello, > >Hope you are having a good time. I am publishing byte array using ZeroMQ in >C#. Please see the publisher here (https://pastebin.com/PJ7f2TJ5 ) > >I am trying to receive this byte array in C++. Please see the subscriber in >C++ here (https://pastebin.com/JKf0cZjh ) > >I want to know that how to receive the sent bytes in C++? > >- > >Thanks >Ravi >______________________________ _________________ >zeromq-dev mailing list >[email protected] >https://lists.zeromq.org/ mailman/listinfo/zeromq-dev > _______________________________________________ zeromq-dev mailing list [email protected] https://lists.zeromq.org/mailman/listinfo/zeromq-dev _______________________________________________ zeromq-dev mailing list [email protected] https://lists.zeromq.org/mailman/listinfo/zeromq-dev _______________________________________________ zeromq-dev mailing list [email protected] https://lists.zeromq.org/mailman/listinfo/zeromq-dev _______________________________________________ zeromq-dev mailing list [email protected] https://lists.zeromq.org/mailman/listinfo/zeromq-dev
