• Stars
    star
    256
  • Rank 159,219 (Top 4 %)
  • Language
    Python
  • License
    The Unlicense
  • Created almost 13 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

netcat for ØMQ. Small but powerful.

zmqc

zmqc is a small but powerful command-line interface to ØMQ. It allows you to create a socket of a given type, bind or connect it to multiple addresses, set options on it, and receive or send messages over it using standard I/O, in the shell or in scripts. It's useful for debugging and experimenting with most possible network topologies.

Installation

pip install zmqc

Usage

zmqc [-h] [-v] [-0] [-r | -w] (-b | -c) SOCK_TYPE [-o SOCK_OPT=VALUE...] address [address ...]

Mode

Whether to read from or write to the socket. For PUB/SUB sockets, this option is invalid since the behavior will always be write and read respectively. For REQ/REP sockets, zmqc will alternate between reading and writing as part of the request/response cycle.

-r, --read
Read messages from the socket onto stdout.
-w, --write
Write messages from stdin to the socket.

Behavior

-b, --bind
Bind to the specified address(es).
-c, --connect
Connect to the specified address(es).

Socket Parameters

SOCK_TYPE
Which type of socket to create. Must be one of `PUSH`, `PULL`, `PUB`, `SUB`, `REQ`, `REP` or `PAIR`. See `man zmq_socket` for an explanation of the different types. `DEALER` and `ROUTER` sockets are currently unsupported.
-o SOCK_OPT=VALUE, --option SOCK_OPT=VALUE
Socket option names and values to set on the created socket. Consult `man zmq_setsockopt` for a comprehensive list of options. Note that you can safely omit the `ZMQ_` prefix from the option name. If the created socket is of type `SUB`, and no `SUBSCRIBE` options are given, the socket will automatically be subscribed to everything.
address
One or more addresses to bind/connect to. Must be in full ZMQ format (e.g. `tcp://:`)

Examples

zmqc -rc SUB 'tcp://127.0.0.1:5000'

Subscribe to tcp://127.0.0.1:5000, reading messages from it and printing them to the console. This will subscribe to all messages by default (you don't need to set an empty SUBSCRIBE option). Alternatively:

zmqc -rc SUB -o SUBSCRIBE='com.organization.' 'tcp://127.0.0.1:5000'

This will subscribe to all messages starting with com.organization..


ls | zmqc -wb PUSH 'tcp://*:4000'

Send the name of every file in the current directory as a message from a PUSH socket bound to port 4000 on all interfaces. Don't forget to quote the address to avoid glob expansion.


zmqc -rc PULL 'tcp://127.0.0.1:5202' | tee $TTY | zmqc -wc PUSH 'tcp://127.0.0.1:5404'

Read messages coming from a PUSH socket bound to port 5202 (note that we're connecting with a PULL socket), echo them to the active console, and forward them to a PULL socket bound to port 5404 (so we're connecting with a PUSH).


zmqc -n 10 -0rb PULL 'tcp://*:4123' | xargs -0 grep 'pattern'

Bind to a PULL socket on port 4123, receive 10 messages from the socket (with each message representing a filename), and grep the files for 'pattern'. The -0 option means messages will be NULL-delimited rather than separated by newlines, so that filenames with spaces in them are not considered two separate arguments by xargs.


echo "hello" | zmqc -c REQ 'tcp://127.0.0.1:4000'

Send the string hello through a REQ socket connected to localhost on port 4000, print whatever you get back, and finish. In this way, REQ sockets can be used for a rudimentary form of RPC in shell scripts.


coproc zmqc -b REP 'tcp://*:4000'
tr -u '[a-z]' '[A-Z]' <&p >&p &
echo "hello" | zmqc -c REQ 'tcp://127.0.0.1:4000'

First, start a REP socket listening on port 4000. The coproc shell command runs this as a shell coprocess, which allows us to run the next line, tr. This will read its input from the REP socket's output, translate all lowercase characters to uppercase, and send them back to the REP socket's input. This, again, is run in the background. Finally, connect a REQ socket to that REP socket and send the string hello through it: you should just see the string HELLO printed on stdout.

(Un)license

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

More Repositories

1

humanhash

Human-readable digests.
Python
852
star
2

markdoc

A lightweight Markdown-based wiki system. Current status: abandoned.
Python
347
star
3

jsonpipe

Convert JSON to a UNIX-friendly line-based format.
Python
302
star
4

urlobject

Python library for manipulating URLs (and some URIs) in a more natural way.
Python
188
star
5

django-postgres

First-class Postgres feature support for the Django ORM.
Python
184
star
6

dagny

Rails-style Resource-Oriented Architecture for Django.
Python
158
star
7

django-conch

Expose the Django shell as an SSH server.
Python
147
star
8

cssmin

*NO LONGER MAINTAINED*. A Python port of the YUI CSS compression algorithm.
Python
133
star
9

teena

Python ports of useful syscalls, using asynchronous I/O.
Python
110
star
10

zenqueue

An incredibly simple (but fast) network message queueing system, written in Python.
Python
66
star
11

django-castor

A content-addressable storage backend for Django.
Python
56
star
12

django-qmethod

Easily define methods over collections of Django models.
Python
54
star
13

django-boss

Simpler Django management commands, powered by argparse.
Python
54
star
14

gevent-psycopg2

Obsolete; use https://bitbucket.org/dvarrazzo/psycogreen/ instead.
Python
51
star
15

django-qmixin

A Django app for extending managers and the querysets they produce.
Python
42
star
16

django-exceptional

A Django client for Exceptional (getexceptional.com)
Python
42
star
17

rkquery

jQuery for Riak, in Python.
Python
31
star
18

uptheasset

[OBSOLETE] Double-entry bookkeeping and accounting, powered by RDF.rb and UNIX.
Ruby
30
star
19

slugify

A generic slugifier (currently only for Latin-based scripts).
Python
29
star
20

django-clsview

Yet another class-based view system for Django.
Python
25
star
21

websession

Information on WebSession, a proposed protocol for secure session maintenance on the Web
JavaScript
21
star
22

gevent-threading-comparison

An experiment to compare the performances of gevent and threading.
Python
17
star
23

calabash

Bash-style pipelining for Python generators.
Python
17
star
24

pdiffer

A Python interface to the PerceptualDiff tool.
Python
16
star
25

django-qmanager

Create managers for Django models based on pre-defined queries.
Python
15
star
26

daterange

Python utility like xrange(), but for datetime objects.
Python
13
star
27

python-csiphash

The SipHash-2-4 C reference implementation, CFFI-wrapped for Python
Python
12
star
28

amoebajs

A WebAssembly-based linear constraint solver for JavaScript
JavaScript
12
star
29

gevent-selfpipe

Hack to run blocking calls whilst maintaining gevent-based synchronization.
Python
12
star
30

urecord

A structured record metaclass for Python.
Python
12
star
31

django-zskel-project

Zack’s Skeleton Django Project.
Python
11
star
32

glyphicons-splitter

Produce individual SVGs and PDFs of the Glyphicons.
Python
10
star
33

django-retracer

Store and restore old locations in Django.
Python
10
star
34

zrpc

ZeroMQ-based JSON-RPC in Python.
Python
9
star
35

pathobject

An update of Jason Orendorff’s path.py.
Python
9
star
36

pyhoudini

Houdini bindings for Python (c.f. https://github.com/vmg/houdini)
9
star
37

relations

A tiny relational algebra engine for Python.
Python
7
star
38

django-cssmin

Easy CSS compression for Django.
Python
6
star
39

strscan

A simple string scanner class for Python. Useful for building lexers/tokenizers by hand.
Python
6
star
40

flask-resource

Build resource-oriented Web apps with Flask.
Python
6
star
41

blog.zacharyvoase.com

Zachary Voase’s nanoc3-powered blog.
Ruby
5
star
42

bossy

Write commands in Python, run them from the shell.
Python
4
star
43

python-crbtree

SortedDict and SortedSet implementations backed by a red-black tree, written in C.
C
4
star
44

python-recordinality

An implementation of the Recordinality sketch in Python, with a CLI
Python
4
star
45

exchequer

Easy table formatting in Python and on the command-line.
Python
4
star
46

django-jsmin

Easy JavaScript minification for Django.
JavaScript
4
star
47

djanjinja

Seamless Jinja2 integration with Django.
Python
3
star
48

broker

Python function dispatching based on MIME types and Accept headers.
Python
3
star
49

pistachio

An experimental Mustache implementation in Python.
Python
3
star
50

logbook-zmqpush

Python
2
star
51

croaring.py

Fast integer sets for Python, based on Roaring Bitmaps and CFFI
Python
2
star
52

llvmbc-wasm-loader

Webpack loader which converts LLVM bytecode to WASM using Emscripten
JavaScript
2
star
53

curly

Use the curl command line interface from Python with minimal fuss.
Python
2
star
54

swipecheck

SwipeCheck: Check into Foursquare using RFID/Twilio.
Python
2
star
55

metaspace

Create Python sub-modules using class syntax.
Python
2
star
56

python-cskipdict

A CFFI-based SkipDict implementation for Python.
C++
2
star
57

logbook-gevent

Experimental support for greenlet-based contexts in Logbook.
Python
2
star
58

skeleton.rb

A skeleton for Ruby projects (using Rake, RSpec, YARD and Bundler)
Ruby
2
star
59

compass-tfg-plugin

A Compass-compatible Sass port of the Tiny Fluid Grid system, plus extras.
Ruby
2
star
60

lovedb

The LoveDB spec.
1
star
61

word2vec

Automatically exported from code.google.com/p/word2vec
C
1
star
62

zacharyvoase.com

The nanoc-powered source of zacharyvoase.com.
PHP
1
star
63

assert_changes

Test assertions about changes in monitored values.
Python
1
star
64

hotqueue

HotQueue is a Python library that allows you to use Redis as a message queue within your Python programs.
Python
1
star
65

django-migrationbug-poc

A proof-of-concept for a bug in Django v1.8 migrations
Python
1
star
66

Adelie

The Ghost theme which powers my blog at zacharyvoase.com
CSS
1
star
67

jpipe

Manipulate JSON at the command-line easily with this line-based formatter
Go
1
star
68

try

A Try monad for Java 8
Java
1
star
69

tipsum

Lorem ipsum using the testing-in-python archive as the text corpus for a Markov chain
Python
1
star
70

stitch-test

Created with StackBlitz ⚡️
TypeScript
1
star
71

czmqc

zmqc, re-implemented in portable C.
C
1
star
72

logbook-zmqcentral

Centralized ZMQ_PUB/SUB-based logging for Logbook.
1
star
73

ninja-builder

JS/Typescript utility for building ninja build files programmatically.
TypeScript
1
star