Aahh! I have to admit that I had no idea you could switch around who binds and who connects, brilliant!
Thanks for your help guys. I have changed to pub/sub and switched round bind/connect and it works perfectly. Thanks again! On 12 May 2011 23:10, Fabien Ninoles <[email protected]> wrote: > > 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://127.0.0.1:6000') > >>> logserver = zmq.Socket(context, zmq.SUB) > >>> logserver.bind('tcp://*:6000') > >>> logclient = zmq.Socket(context, zmq.SUB) > >>> logclient.connect('tcp://127.0.0.1:5000') > >>> logserver.setsockopt(zmq.SUBSCRIBE, '') > >>> logclient.setsockopt(zmq.SUBSCRIBE, '') > >>> logger.send('Hello') > >>> logclient.recv() > 'Hello' > >>> logserver.recv() > 'Hello' > >>> > > Fabien > > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > > -- Gehan
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
