[zeromq-dev] can use SUB and PUSH together with device?

timger™ yishenggudou at gmail.com
Tue Jan 29 06:59:02 CET 2013


timger™


On Tue, Jan 29, 2013 at 1:36 PM, Michel Pelletier <
pelletier.michel at gmail.com> wrote:

> From: http://api.zeromq.org/2-1:zmq-device
>
> "You should use *ZMQ_STREAMER* with a *ZMQ_PULL* socket for the frontend
> and a*ZMQ_PUSH* socket for the backend. Other combinations are not
> documented."
>
> That being said, you wrote the code, does it work?
>

yes
It can run seemingly no problem
But I do not know whether this will cause other problems


>
> -Michel
>
>
> On Mon, Jan 28, 2013 at 7:05 PM, timger™ <yishenggudou at gmail.com> wrote:
>
>> hi all
>> I want to recv message from pub broadcast
>> and then distribute the message to some other process
>>
>> if I can use SUB and PUSH together with device?
>>
>> and some code like :
>>
>> import zmq
>> import yaml
>> from time import sleep
>> conf = yaml.load(open('offline.yaml'))
>>
>>
>> class Qsuber(object):
>>
>>     def __init__(self):
>>         self.context = zmq.Context()
>>         self.client_id = conf['clientid']
>>         self.sub_connect()
>>         self.push_bind()
>>
>>     def sub_connect(self):
>>         self.socket = self.context.socket(zmq.SUB)
>>         self.socket.setsockopt(zmq.SUBSCRIBE, "")
>>         self.socket.setsockopt(zmq.IDENTITY, self.client_id)
>>         self.socket.connect(conf['zmqsub'])
>>
>>     def push_bind(self):
>>         sleep(0.1)
>>         self.push_socket = self.context.socket(zmq.PUSH)
>>         self.push_socket.setsockopt(zmq.HWM, 0)
>>         self.push_socket.bind(conf['zmqpush'])
>>
>>     def recv(self):
>>         zmq.device(zmq.STREAMER, self.socket, self.push_socket)
>>
>> if __name__ == "__main__":
>>     main = Qsuber()
>>     main.recv()
>>
>>
>> timger™
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>>
>
> _______________________________________________
> 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/20130129/ceab4f75/attachment.htm>


More information about the zeromq-dev mailing list