diff --git a/0mq_client.py b/0mq_client.py new file mode 100644 index 0000000..a8535c6 --- /dev/null +++ b/0mq_client.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +from sys import argv + +host = argv[1] if argv[1] else "127.0.0.1" + +serv = "tcp://" + host + ":5555" + +import zmq + +context = zmq.Context() +print("Verbinde zu %s" % serv) +socket = context.socket(zmq.SUB) + +socket.connect(serv) + +socket.setsockopt_string(zmq.SUBSCRIBE, "MSG") + +while True: + line = socket.recv_string() + print("< "+ line) + diff --git a/0mq_server.py b/0mq_server.py new file mode 100644 index 0000000..1003e78 --- /dev/null +++ b/0mq_server.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +import zmq + +context = zmq.Context() + +server = context.socket(zmq.PUB) +server.bind("tcp://*:5555") + +while True: + line = input("> ") + server.send_string("MSG %s" % line)