[zeromq-dev] Ruby zmq.send error

Conrad Steenberg conrad.steenberg at gmail.com
Thu Jul 30 18:53:22 CEST 2009


Hi Martin,

The RSTRING() macro also checks for zeroes in the string, and throws the
same error.

Attached is a patch that uses StringValuePtr() instead, which works for
me.

Thanks,
Conrad

On Thu, 2009-07-30 at 13:13 +0200, Martin Sustrik wrote:
> Hi Conrad,
> 
> > I'm trying to send a message using the ruby binding with
> > zmq.send(@eid, msg, msg.length, ZMQ_TRUE)
> > 
> > and get the following:
> > test.rb:76:in `send': string contains null byte (ArgumentError)
> > 
> > In my mind that's a bug :-)
> > 
> >>From librbzmq.cpp:142:
> > memcpy (msg.data (), (void*) StringValueCStr (data_),
> >         (size_t) NUM2ULL (size_));
> > 
> > Is there an alternative to StringValueCStr(data_) to create the data for
> > the message?
> 
> What about something like this:
> 
>      zmq::message_t msg ((size_t) RSTRING (data_)->len);
>      memcpy (msg.data (), (void*) RSTRING (data_)->ptr,
>      	RSTRING (data_)->len);
> 
> (Actually, thinking about it, it seems that size_ argument of send 
> function is not needed at all.)
> 
> Would that work for you?
> 
> Martin
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zmq-ruby.diff
Type: text/x-patch
Size: 503 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20090730/80a7ce16/attachment.bin>


More information about the zeromq-dev mailing list