[zeromq-dev] Ruby zmq.send error

Martin Sustrik sustrik at fastmq.com
Thu Jul 30 13:13:01 CEST 2009


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



More information about the zeromq-dev mailing list