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

MinRK benjaminrk at gmail.com
Thu Sep 29 01:14:26 CEST 2011

On Wed, Sep 28, 2011 at 15:33, Pieter Hintjens <ph at imatix.com> wrote:

> On Wed, Sep 28, 2011 at 2:54 PM, Elliot Saba <staticfloat at gmail.com>
> wrote:
> > Hey Martin, for some reason it's not working for me.  My messages appear
> to
> > be dropped by the ROUTER socket before leaving the interface.
> > Does the introduction of the LABEL flag have anything to do with this?
> >  Right now I am sending the "address" of the peer I wish to talk to with
> > just a ZMQ_SNDMORE flag, do I need to use ZMQ_SNDLABEL or anything like
> > that?
> You're using version 3.0? Then you do need to set ZMQ_SNDLABEL, yes.

No, ROUTER sockets in 3.0 are identical to 2.1 - they do not use LABELs at

Python example:

import time
import zmq

ctx = zmq.Context()
router = ctx.socket(zmq.ROUTER)
a = ctx.socket(zmq.REP)
# you must set ident before connecting:
a.setsockopt(zmq.IDENTITY, 'a')
# wait for connection to be established - otherwise messages will drop
router.send('a', zmq.SNDMORE)

print 'receiving...'
msg = a.recv() # will hang here, if it didn't work
print "a got %r" % msg # will be 'hi'
print "router got back %r" % router.recv_multipart() # will be ['a', 'hi']


> -Pieter
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110928/cf19bf3b/attachment.htm>

More information about the zeromq-dev mailing list