Skip to content

Instantly share code, notes, and snippets.

@HenryYoung42
Created October 21, 2019 12:08
Show Gist options
  • Save HenryYoung42/d9e190dbc5d6fd407c34a69bb87e3f47 to your computer and use it in GitHub Desktop.
Save HenryYoung42/d9e190dbc5d6fd407c34a69bb87e3f47 to your computer and use it in GitHub Desktop.
ZMQ Test Subscriber in Python3
import zmq
def main():
# Prepare our context and publisher
context = zmq.Context()
subscriber = context.socket(zmq.SUB)
subscriber.connect("tcp://127.0.0.1:28000")
subscriber.setsockopt(zmq.SUBSCRIBE, b"")
while True:
# Read envelope with address
[address, contents] = subscriber.recv_multipart()
print("[%s] %s" % (address, contents))
# We never get here but clean up anyhow
subscriber.close()
context.term()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment