[zeromq-dev] Question regarding handshake(?) message

Martin Sustrik sustrik at 250bpm.com
Fri Mar 19 14:38:16 CET 2010



Hi Thijs,

>I am currently learning about ZeroMQ and reading the online docs and
>mailing list has been helpful so far.
>
>My usage: a server (written in Erlang) listens to a certain IP:Port
>and workers (written in C++, using the ZeroMQ library ZMQ_REP type)
>connecting to the server. The server sends tasks to the workers and
>one of the workers handles the task. Since there is no Erlang client,
>I wrote my own very simple partial implementation, more or less just
>based on TCP sockets + round-robin routing. I considered making an
>Erlang driver, but the design ended up being quite complex.

For the long-term usage an Erlang driver would be better, but
implementing the wire protocol by hand is a viable temporary solution.

>
>Two questions:
>
>1. When the workers connect to the Erlang server, they seem to send a
>packet <<1,0>> (first byte value 1 (length) and then \0 byte). Where
>can I find the meaning of this handshake? Is it in fact a handshake or
>does such a concept even exist in ZeroMQ? I didnt see it mentioned
>anywhere.

The first message sent (by both peers) is identity of the peer. In other
words, each peer introduces itself to the other peer. The default
behaviour is to send an empty message (<<1,0>>).

Thus you have to both send such a message yourself and receive it from
your peer before starting any further work.

>2. The packet format of the messages seems to be <<Length:8, 0:8,
>Data/binary>> (for small messages, I'm aware of the alternative for
>large messages). I'm not sure where this second byte comes from? I
>didnt expect it based on this description of the wire format :
>http://www.zeromq.org/whitepapers:design-v01 Perhaps this whitepaper
>is not up-to-date anymore, if so: I want to suggest to add a notice on
>the top of each whitepaper that it refers to an older version.

Yes, the wire format was changed slightly. See here:

http://api.zeromq.org/zmq_tcp.html

>Besides that, thanks for all the work you do for ZeroMQ. It's a very
>interesting MQ-approach and I intend to study it much more.

Thanks and good luck!

Martin



More information about the zeromq-dev mailing list