Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

messaging interface is unnecessarily low-level and confusing #46

Closed
StefanKarpinski opened this issue Feb 4, 2014 · 3 comments
Closed

Comments

@StefanKarpinski
Copy link
Contributor

The Message type seems very unnecessary and like it exposes a lot of dangerous and confusing low-level details about how ZMQ works internally. Why doesn't ZMQ.send just take a array of bytes as its second argument? Why doesn't ZMQ.recv just return an array of bytes? ZMQ is message-oriented and each message is just an array of bytes. If someone wants to write to a buffer and then send that, they can do exactly that – construct an IOBuffer object themselves and then send the bytes it contains. To be helpful, ZMQ.send could easily allow passing an IOBuffer value as its second argument. You could even expose this interface:

ZMQ.send(s) do io
  # write stuff to io
end

ZMQ.recv(s) do io
  # read stuff from io
end

Is there any real reason to ever expose the Message type to the programmer?

@stevengj
Copy link
Contributor

stevengj commented Feb 4, 2014

Note that recv does "just return an array of bytes," since Message <: AbstractVector{Uint8}. And you really want to return the zmq_msg wrapper directly, rather than copying to Vector{Uint8} or similar, so that you can read the data in-place for a large message.

However, send could certainly support higher-level interfaces.

@stevengj
Copy link
Contributor

stevengj commented Feb 5, 2014

(That's also why the Message type is potentially useful for sending too: you might want to be accessing the data in a read-only fashion while you are sending it, without making a copy.)

@JamesWrigley
Copy link
Member

I'm gonna close this because as of #186 we can use send()/recv() with regular Julia types without needing to bother with Message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants