https://github.com/bpkg/umq
tcp message pushing and receiving in bash
https://github.com/bpkg/umq
Last synced: 12 months ago
JSON representation
tcp message pushing and receiving in bash
- Host: GitHub
- URL: https://github.com/bpkg/umq
- Owner: bpkg
- Created: 2013-12-21T03:03:01.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-26T04:44:27.000Z (almost 12 years ago)
- Last Synced: 2025-03-27T05:03:06.887Z (about 1 year ago)
- Language: Shell
- Homepage:
- Size: 250 KB
- Stars: 30
- Watchers: 14
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
umq
=====
tcp message pushing and receiving in bash
## install
[bpkg](https://github.com/bpkg/bpkg)
```sh
$ bpkg install umq -g
```
```sh
$ make
$ make check
$ make install
```
## usage
**server**
Listening on localhost can be achieved by simple providing a port:
```sh
$ umq recv 3000 | { \
while read -r line; do \
echo "got: '$line'"; \
done; \
}
```
This will create a server and listen on localhost port `3000` for all incoming tcp messages.
**connecting**
You can connect and read from the server by using `umq recv` with a host and port:
```sh
$ umq recv localhost 3000
```
**pushing**
Pushing data to a umq receiver can be performed via `umq push`:
```sh
$ echo "ping" | umq push localhost 3000
```
This should yield the following response on the server:
```
got: 'ping'
```
## api
```sh
usage: umq [-hV]
examples:
$ echo "hello world" | umq push localhost 3000
$ umq recv localhost 3000 | while read line; do \
echo "msg: $line"; done
commands:
push push message to host with port
recv receive message on host with port
help see more information on a command
options:
-h, --help display this message
-V, --version output version
```
## examples
### cpu histogram
Using `umq` with [histo](https://github.com/visionmedia/histo) allows
for data to be streamed via tcp to a histo chart
See [cpu-stream](https://gist.github.com/jwerle/8076956) for a preview.
### wall server
Streaming messages to `wall`.
See [wall-server](https://github.com/jwerle/umq/blob/master/examples/wall-server.sh).
## caveats
When multiple peers are connected via `umq recv ` to a single umq receiver, messages are emitted to
each peer via the (RR) [Round-Robin](http://en.wikipedia.org/wiki/Round-robin_scheduling) technique. For example:
**server**
```sh
$ umq recv 3000 | while read -r chunk; do echo "chunk: $chunk"; done
chunk:
chunk: 0
chunk: 1
chunk: 2
chunk: 3
chunk: 4
chunk: 5
chunk: 6
chunk: 7
chunk: 8
chunk: 9
chunk: 10
chunk: 11
```
**pusher**
```sh
$ i=0 while true; do echo echo "$i"; ((++i)); sleep .5; done | umq push localhost 3000
```
**peer 1**
```sh
$ umq recv localhost 3000
2
3
4
5
8
9
10
11
```
**peer 2**
```sh
$ umq recv localhost 3000
6
7
```
## license
MIT