lib/0mq/socket.rb in 0mq-0.2.0 vs lib/0mq/socket.rb in 0mq-0.2.1
- old
+ new
@@ -67,10 +67,11 @@
ZMQ.error_check true if rc==-1
end
# Send a string to the socket
def send_string(string, flags = 0)
+ string = string.to_s
size = string.respond_to?(:bytesize) ? string.bytesize : string.size
@msgbuf = LibC.malloc size
@msgbuf.write_string string, size
rc = LibZMQ.zmq_msg_init_data @msgptr, @msgbuf, size, LibC::Free, nil
@@ -99,14 +100,13 @@
str
end
# Send a multipart message as an array of strings
- def send_array(ary)
- last = ary.last
-
- ary[0...-1].each { |str| send_string str, ZMQ::SNDMORE }
- send_string last
+ def send_array(array)
+ array = array.to_a
+ array[0...-1].each { |str| send_string str, ZMQ::SNDMORE }
+ send_string array.last
end
# Receive a multipart message as an array of strings
def recv_array
[].tap do |ary|