one-file-projects/0mq_client.py

23 lines
361 B
Python
Raw Normal View History

2016-06-23 15:17:59 +02:00
#!/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)