Skip to content
/ umq Public

tcp message pushing and receiving in bash

Notifications You must be signed in to change notification settings

bpkg/umq

Repository files navigation

umq

tcp message pushing and receiving in bash

install

bpkg

$ bpkg install umq -g
$ make
$ make check
$ make install

usage

server

Listening on localhost can be achieved by simple providing a port:

$ 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:

$ umq recv localhost 3000

pushing

Pushing data to a umq receiver can be performed via umq push:

$ echo "ping" | umq push localhost 3000

This should yield the following response on the server:

got: 'ping'

api

usage: umq <command> [-hV]

examples:
$ echo "hello world" | umq push localhost 3000
$ umq recv localhost 3000 | while read line; do \
      echo "msg: $line"; done

commands:
  push <host> <port>      push message to host with port
  recv <host> <port>      receive message on host with port
  help <command>          see more information on a command

options:
  -h, --help              display this message
  -V, --version           output version

examples

cpu histogram

Using umq with histo allows for data to be streamed via tcp to a histo chart

See cpu-stream for a preview.

wall server

Streaming messages to wall.

See wall-server.

caveats

When multiple peers are connected via umq recv <host> <port> to a single umq receiver, messages are emitted to each peer via the (RR) Round-Robin technique. For example:

server

$ 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

$ i=0 while true; do echo echo "$i"; ((++i)); sleep .5; done | umq push localhost 3000

peer 1

$ umq recv localhost 3000

2
3
4
5
8
9
10
11

peer 2

$ umq recv localhost 3000

6
7

license

MIT

About

tcp message pushing and receiving in bash

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages