[zeromq-dev] Help needed choosing socket strategy
Ian Barber
ian.barber at gmail.com
Fri Dec 7 20:53:58 CET 2012
On Tue, Dec 4, 2012 at 8:38 PM, Adrian Ribao <aribao at gmail.com> wrote:
>
> ----
> context = zmq.Context()
> print "Starting the proxy..."
>
> # Listen for events
> sub = context.socket(zmq.SUB)
> sub.bind("tcp://*:5555")
> sub.setsockopt(zmq.SUBSCRIBE, '')
>
> # Emit events
> pub = context.socket(zmq.PUB)
> pub.bind("tcp://*:5556")
>
> while True:
> message = sub.recv()
> pub.send(message)
> ----
>
>
Very common use of a proxy to be the stable part in an architecture, to
allow publishers and consumers to come and go. If you look in the python
bindings you'll see support for devices or proxies (old name / new name)
which actually do what you've written, but slightly more optimised, with
support for multipart messages. You've got the gist though.
Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121207/7c217a97/attachment.htm>
More information about the zeromq-dev
mailing list