From fa7011a71e1f4f4cc858f5c1be17d6b3231bacec Mon Sep 17 00:00:00 2001 From: Tim Donegan Date: Tue, 10 Jun 2014 23:53:35 -0700 Subject: [PATCH] added multipart envelope support --- src/ZMQ.jl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ZMQ.jl b/src/ZMQ.jl index 5acc1d7..4cb16fb 100644 --- a/src/ZMQ.jl +++ b/src/ZMQ.jl @@ -502,6 +502,13 @@ function send(socket::Socket, zmsg::Message, flag=int32(0)) throw(StateError(jl_zmq_error_str())) end end + +function send_multipart(socket::Socket, parts::Array{Message}) + for msg in parts[1:end-1] + send(socket, msg, SNDMORE) + end + return send(socket, parts[end]) +end end # end v3only # strings are immutable, so we can send them zero-copy by default @@ -558,6 +565,15 @@ function recv(socket::Socket) end return zmsg end + +function recv_multipart(socket::Socket) + parts = Any[recv(socket)] + while ismore(socket) + push!(parts, recv(socket)) + end + + return parts +end end # end v3only ## Constants