Create a gist now

Instantly share code, notes, and snippets.

import sys
import zmq
if (len(sys.argv) != 2):
print("Usage: # python3 {} <channel>".format(sys.argv[0]))
ch = sys.argv[1]
# ZeroMQ のバックグラウンド・スレッドのコンテキスト
context = zmq.Context()
# このサーバは、ポート5556で待ちます
socket = context.socket(zmq.SUB)
# Channel をサブスクライブ
socket.setsockopt_string(zmq.SUBSCRIBE, ch)
while True:
string = socket.recv_string()
ch, data = string.split()
print("Ch {0} -> {1} received".format(ch, data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment