[zeromq-dev] Is custom HWM behaviour possible?

Fabien Ninoles fabien.ninoles at ubisoft.com
Fri May 13 00:10:40 CEST 2011

> I've been playing with zmq and its great, I want to use it to enable our 5
> servers to push out logging messages to a log server to store it
> centrally. Some people would set the 5 servers up as publishers with the
> log server as a subscriber, but that requires the log server to know where
> all the other servers are, whereas I'd rather have it the other way round.

All socket types can both bind and connect, even on the same socket.  So,
just connect your PUB loggers to a well known SUB log server.  And, why not
also bind some ports so that you can connect a log client to listen to only
this server at the same time ?

Here a small sample of this code in python:

>>> import zmq
>>> context = zmq.Context()
>>> logger = zmq.Socket(context, zmq.PUB)
>>> logger.bind('tcp://*:5000')
>>> logger.connect('tcp://')
>>> logserver = zmq.Socket(context, zmq.SUB)
>>> logserver.bind('tcp://*:6000')
>>> logclient = zmq.Socket(context, zmq.SUB)
>>> logclient.connect('tcp://')
>>> logserver.setsockopt(zmq.SUBSCRIBE, '')
>>> logclient.setsockopt(zmq.SUBSCRIBE, '')
>>> logger.send('Hello')
>>> logclient.recv()
>>> logserver.recv()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110512/889f28b6/attachment.htm>

More information about the zeromq-dev mailing list