Commit 759f9b6e authored by Kei Tsuji's avatar Kei Tsuji

update pub-sub example

parent 06b4e37d
...@@ -9,7 +9,10 @@ context = zmq.Context() ...@@ -9,7 +9,10 @@ context = zmq.Context()
socket = context.socket(zmq.PUB) socket = context.socket(zmq.PUB)
socket.bind('tcp://*:5555') socket.bind('tcp://*:5555')
for i in range(5): for i in range(5000):
socket.send(b'status 5') # socket.send(b'status 5')
# socket.send(b'statuses')
s = f'status {i}'
socket.send(s.encode('ascii'))
socket.send(b'All is well') socket.send(b'All is well')
time.sleep(1) time.sleep(1)
...@@ -9,6 +9,7 @@ context = zmq.Context() ...@@ -9,6 +9,7 @@ context = zmq.Context()
socket = context.socket(zmq.SUB) socket = context.socket(zmq.SUB)
socket.connect('tcp://localhost:5555') socket.connect('tcp://localhost:5555')
socket.setsockopt(zmq.SUBSCRIBE, b'status') socket.setsockopt(zmq.SUBSCRIBE, b'status')
# socket.setsockopt(zmq.SUBSCRIBE, b'')
while True: while True:
message = socket.recv_multipart() message = socket.recv_multipart()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment