The usual convention (it's described in the Guide pretty early on) is to not send or assume trailing null characters. zstr_send/recv remove and add the null characters explicitly. Expecting a null in the raw message data is wrong... and your fix is correct.
On Sun, Dec 1, 2013 at 7:11 PM, Brian Knox <[email protected]> wrote: > So - for fun I patched my local libzmq and changed the length check to not > take the null terminator into account... > > if (msg.size () == 5 && memcmp (msg.data (), "PAUSE", 5) == 0) > > ...and now I can send the PAUSE command using zstr_send - so this confirms > my thought. > > Since the least disruptive change now that I understand what's going on is > just to change my zproxy code to send the full char with terminator using > zmsg rather than zstr, I'll do that - just following up to my question in > case this information is useful to others. > > Brian > > > > > On Sun, Dec 1, 2013 at 10:39 AM, Brian Knox <[email protected]> wrote: >> >> Hello! >> >> I'm working on adding support for zmq_proxy_steerable commands to zproxy >> in czmq. I noticed I was getting an invalid proxy command error when trying >> to send a "PAUSE" command using zstr_send. >> >> Taking a look at the libzmq proxy.cpp code ~ line 117 on libzmq head >> (https://github.com/zeromq/libzmq/blob/master/src/proxy.cpp#L117) , I see: >> >> -------------------------------------------------- >> if (msg.size () == 6 && memcmp (msg.data (), "PAUSE", 6) == 0) >> state = paused; >> ---------------------------------------------------- >> >> My understanding is that zstr_send (from czmq) does not send the NULL at >> the end of the string, and zstr_recv adds one ( >> https://github.com/zeromq/czmq/blob/master/src/zstr.c#L68 ) >> >> While I know libzmq is not czmq - I just want to make sure I understand >> the libzmq code. Should I be sending "PAUSE" with a null terminator, and is >> that why the command check in proxy.cpp is looking for a message size of 6 >> rather than 5? >> >> Thanks! >> Brian > > > > _______________________________________________ > 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
