[zeromq-dev] Connection setup

Brian Candler B.Candler at pobox.com
Wed Apr 21 12:53:58 CEST 2010

Just a few more newcomer comments after having a bit of a play with 0MQ.

I like the idea of having different messaging models bound to different
connections.  It avoids having to tag each individual message as "this is a
PUB with a topic", or "this is a REQ which expects a REP", thus saving those
8 magic flag bits for other uses, and simplifying the code which receives
messages.  And it's reasonable to assume that all the messages in a
particular flow are going to follow the same pattern.

However, it does allow for some errors; for example, you can happily connect
a P2P client to a REP server.

There is an existing initial handshake, which at the moment does nothing
more than exchange peer identities (*).  Maybe it should also say "I'm a
REQ" or "I'm a P2P"?  Then the connection could be dropped if it was an
inappropriate peer.

Now, if you're going to say "I'm a REQ", then you could instead say "I need
to connect to a REP peer".  This means you could run multiple message
patterns on the same port, and provide whichever the client asks for, if the
server wishes to support them.  Extending this further, the client could ask
to talk to a named service, so that multiple distinct services could be
served from the same port.

There are other uses for the initial handshake: e.g. requesting TLS,
providing authentication. Or you could declare the MIME type of the messages
you intend to send, which could also prevent some other foot-shooting.

Anyway, given an empty initial message exchange all this can be easily
retro-fitted, which is a good position to be in :-)



(*) I can't see how the local identity is set, or the remote identity is
read, in the current API.  Have I missed something?

More information about the zeromq-dev mailing list