Im new to ZMQ and trying to set a simple PubSub pattern between CPP publisher and Python Subscriber, my aim is to use the send more mechanism
can't quite understand what is the cause of the error and how to fix it, details below
this is the Publisher code:
zmq::context_t *context;
// Socket to talk to clients
zmq::socket_t *publisher;
...
zmq_bind(this->publisher, this->externalPubLine.c_str()/*ipc:///tmp/MyPub*/);
...
std::array<zmq::const_buffer, 2> send_msgs = {
zmq::str_buffer("more messages !!! it's so fun"), // meta
zmq::const_buffer((const char *)(m->msg.get()), m->msg_size) // data
};
zmq::socket_ref sr = *this->publisher;
auto b = zmq::send_multipart(sr, send_msgs); //send multi part <-- fails here
this is my subscriber code
subscriber.connect('ipc:///tmp/MyPub')
subscriber.setsockopt(zmq.SUBSCRIBE, b'')
while True:
msg = subscriber.recv_multipart()
when running the CPP code it throws the following trace (running using gdb):
terminate called after throwing an instance of 'zmq::error_t'
what(): Socket operation on non-socket
Thread 4 "pub" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff01a5700 (LWP 16229)]
0x00007ffff68bd428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff68bd428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff68bf02a in __GI_abort () at abort.c:89
#2 0x00007ffff720cdde in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff7218896 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff7218901 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff7218b55 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00000000004ac0c4 in zmq::detail::socket_base::send (this=0x7ffff01a4cc8, buf=..., flags=zmq::send_flags::sndmore)
at /home/vm/repo/my_zmq/pub/zmq/zmq.hpp:1827
#7 0x00000000004ac350 in zmq::send_multipart<std::array<zmq::const_buffer, 2ul>&, void> (s=..., msgs=..., flags=zmq::send_flags::none)
at /home/vm/repo/my_zmq/pub/zmq/zmq_addon.hpp:181