[zeromq-dev] Sending object pointers to threads using ZMQ_SEND over ZMQ_PAIR Socket

Shrikanth M.D. shrikanthdiwakar at gmail.com
Tue Dec 20 13:14:26 CET 2016


Hi,

I have tried a small piece of code as in here:
http://pastebin.com/JUxXjYX2


I am using ZEROMQ 4.1.5 library and running on Ubuntu 15.04.
This is how I compile and execute the code:
 gcc zeromq_example.c -o a.out -lzmq -lpthread



When I compile the example code in the link as sudo user, I am able to
successfully receive
the struct content on the thread side.
However, occasionally I observe ZMQ_Receive  error. Is this because I am
executing my program too quickly again in the second run?

Below is the output:
shrikanth at mds:~$ sudo ./a.out
The values received are 1000 5000 100 500 HelloWorld
shrikanth at mds:~$ sudo ./a.out
Error in Receiving
The values received are -1052453120 32596 1 0
shrikanth at mds:~$ sudo ./a.out
The values received are 1000 5000 100 500 HelloWorld
shrikanth at mds:~$


Also, without sudo user, although buffer contents are received by the
thread, it ends up with a segmentation fault (may be because of the memory
access to struct sample within the struct example).

Could you please suggest a workaround for this situation?
I do not want to serialize/de-serialize stuff between my main thread and
worker thread.

Any kind of input is deeply appreciated.

Regards,
Shrikanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20161220/1786a67a/attachment.htm>


More information about the zeromq-dev mailing list