diff --git a/lib/celluloid/zmq/sockets.rb b/lib/celluloid/zmq/sockets.rb index 34cf969..9d5f2d9 100644 --- a/lib/celluloid/zmq/sockets.rb +++ b/lib/celluloid/zmq/sockets.rb @@ -90,7 +90,17 @@ def read(buffer = '') end buffer end + + # Read a multipart string message from the socket + def read_multipart(buffer = []) + ZMQ.wait_readable(@socket) if ZMQ.evented? + unless ::ZMQ::Util.resultcode_ok? @socket.recv_strings buffer + raise IOError, "error receiving ZMQ string: #{::ZMQ::Util.error_string}" + end + buffer + end + end # Multiparts message ? def_delegator :@socket, :more_parts? end @@ -99,6 +109,8 @@ def read(buffer = '') module WritableSocket # Send a message to the socket def write(*messages) + ZMQ.wait_writable(@socket) if ZMQ.evented? + unless ::ZMQ::Util.resultcode_ok? @socket.send_strings messages.flatten raise IOError, "error sending 0MQ message: #{::ZMQ::Util.error_string}" end