summaryrefslogtreecommitdiffstats
path: root/doc/zmq-ctrl/zmq_remote.py
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-08-01 15:38:04 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-08-01 15:38:04 +0200
commit0fc699073e89209fbb6bf1345cb562601760fbe6 (patch)
tree9b10796ccd0c00eac3f12b8832b9fa448cd41d1a /doc/zmq-ctrl/zmq_remote.py
parent0a17f5cf27e221b680617e2c522306d27bd6f141 (diff)
downloaddabmod-0fc699073e89209fbb6bf1345cb562601760fbe6.tar.gz
dabmod-0fc699073e89209fbb6bf1345cb562601760fbe6.tar.bz2
dabmod-0fc699073e89209fbb6bf1345cb562601760fbe6.zip
Add simple zmq remote python script
Diffstat (limited to 'doc/zmq-ctrl/zmq_remote.py')
-rwxr-xr-xdoc/zmq-ctrl/zmq_remote.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/doc/zmq-ctrl/zmq_remote.py b/doc/zmq-ctrl/zmq_remote.py
new file mode 100755
index 0000000..dffe53e
--- /dev/null
+++ b/doc/zmq-ctrl/zmq_remote.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python2
+
+import sys
+import zmq
+
+context = zmq.Context()
+
+sock = context.socket(zmq.REQ)
+
+if len(sys.argv) < 2:
+ print("Usage: program url cmd [args...]")
+ sys.exit(1)
+
+sock.connect(sys.argv[1])
+
+message_parts = sys.argv[2:]
+
+# first do a ping test
+
+print("ping")
+sock.send("ping")
+data = sock.recv_multipart()
+print("Received: {}".format(len(data)))
+for i,part in enumerate(data):
+ print(" {}".format(part))
+
+for i, part in enumerate(message_parts):
+ if i == len(message_parts) - 1:
+ f = 0
+ else:
+ f = zmq.SNDMORE
+
+ print("Send {}({}): '{}'".format(i, f, part))
+
+ sock.send(part, flags=f)
+
+data = sock.recv_multipart()
+
+print("Received: {}".format(len(data)))
+for i,part in enumerate(data):
+ print(" RX {}: {}".format(i, part))
+