zmq Poller

1.注册socket到poller中

poller = zmq.Poller()
poller.register(frontend, zmq.POLLIN) # receive worker message
poller.register(receiver, zmq.POLLIN) # put message to client

 

 

2.接受消息时依据socket标识来判断是该哪个socket接受消息

while True:
    if socks.get(frontend) == zmq.POLLIN:
        frontend.recv_multipart()

    if socks.get(receiver) == zmq.POLLIN:
        receiver.recv_multipart()

 

上一篇:zeromq源码分析笔记之架构(1)


下一篇:Raspberry Zero 上实现平滑视频图传