Skip to content

Instantly share code, notes, and snippets.

@h2suzuki
Last active July 12, 2017 08:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h2suzuki/93d4a0d9f00c65dde61f3a7a1a7a89d8 to your computer and use it in GitHub Desktop.
Save h2suzuki/93d4a0d9f00c65dde61f3a7a1a7a89d8 to your computer and use it in GitHub Desktop.
import zmq
import time
# ZeroMQ のバックグラウンド・スレッドのコンテキスト
context = zmq.Context()
# このサーバは、ポート5556で待ちます
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:5556")
i = 0
while True:
i += 1
for ch in range(1,4):
data = ch * i
socket.send_string("{0} {1}".format(ch, data))
print("Ch {0} <- {1} sent".format(ch, data))
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment