[zeromq-dev] Ruby binding s.recv returns 0-terminated string

Han Holl han.holl at pobox.com
Sat Mar 5 21:49:48 CET 2011


Hi,

The function 
s.recv
returns a string like "OK\000", at least with my ruby-1.8.7.334-1.fc14.x86_64.
Maybe there are ruby implementations that make the trailing zero go away.

The patch isn't that complex:
--- rbzmq.c.orig        2011-03-05 21:38:45.035181613 +0100
+++ rbzmq.c     2011-03-05 21:33:26.524369606 +0100
@@ -1555,7 +1555,7 @@
     }
 
     VALUE message = rb_str_new ((char*) zmq_msg_data (&msg),
-        zmq_msg_size (&msg));
+        zmq_msg_size (&msg) - 1);
     rc = zmq_msg_close (&msg);
     assert (rc == 0);
     return message;

Cheers,

Han Holl

(not sure if non-subscribers are allowed to post, but I'll find out)



More information about the zeromq-dev mailing list