[zeromq-dev] Using a ROUTER to direct messages to a new peer

Martin Sustrik sustrik at 250bpm.com
Wed Sep 28 14:10:04 CEST 2011


Hi Elliot,

> Hello, I'm trying to use a ROUTER socket to communicate to a new peer
> that I have not received any messages from before.  I know that to use a
> ROUTER socket to speak with this peer, I should prepend the peer's
> identity in a separate message part, but I have no way of knowing what
> identity this peer has, as I have not received any packets from it yet.
>   (I am trying to make a peer to peer network using a ROUTER on each
> peer to talk to the rest of the swarm, and this initial message is to
> begin the handshake protocol to setup encryption, etc....)
>
> Is this a network design flaw on my end, or is there an easy way to get
> a peer's ID that I don't know about?

In versions 2.x and 3.x you have ZMQ_IDENTITY option that allows you to 
set the identity by hand. (Thus you can know the identity of the peer in 
advance.)

Martin



More information about the zeromq-dev mailing list