upd: 'README.md' -> new description, added 'trigger-wait' and 'trigger-send'; TODO-README: read, write, pool, master; TODO-DEV: trigger-wait, trigger-send

This commit is contained in:
xdrm-brackets 2018-02-04 14:13:41 +01:00
parent afa4c85cca
commit b81695be5d
1 changed files with 45 additions and 4 deletions

View File

@ -1,8 +1,6 @@
# bash socket utility # bash socket utility
## native calls ## 1. Listen
### 1. bind-input
Binding an input creates a listening socket on a local port and binds the socket data to a local accessible buffer (accessible with the native `read` call). Binding an input creates a listening socket on a local port and binds the socket data to a local accessible buffer (accessible with the native `read` call).
@ -62,7 +60,7 @@ kill -INT $bound_pid;
### 2. bind-output ## 2. Connect
Binding an output creates a local accessible buffer (accessible with the native `write` call) bound to a socket connecting to a certain host and port. Binding an output creates a local accessible buffer (accessible with the native `write` call) bound to a socket connecting to a certain host and port.
@ -104,3 +102,46 @@ write output1 "END";
# 5. Kill 'bind-output' with signal SIGINT, SIGHUP or SIGTERM # 5. Kill 'bind-output' with signal SIGINT, SIGHUP or SIGTERM
kill -INT $bound_pid; kill -INT $bound_pid;
``` ```
## 3. Network trigger
The programs `trigger-send` and `trigger-wait` allows *signals* to be send over the network (private or public).
- `trigger-wait` will wait for a signal to exit.
- `trigger-send` will send a signal to a remote host.
### **trigger-wait**
```bash
trigger-wait $key $port
```
*Arguments:*
- `$key` is a secret string that the sender will have to match.
- `$port` is the local listening port (between 1024 and 49151).
*Exemple:*
Let's say you want to wait for a signal on port 9999 then launch some command (for example `read input1`).
```bash
trigger-wait somekey123 9999; read input1;
```
### **trigger-send**
```bash
trigger-wait $key $host $port
```
*Arguments:*
- `$key` is the same secret string used by the receiver.
- `$host` is the remote hostname (IP addr. or resolvable) to send the messag eto.
- `$port` is the remote port to send the message to (between 1024 and 49151).
*Exemple:*
Let's say you want to execute a long command (sleep 5), then send the trigger to 192.168.0.2 port 9999.
```bash
sleep 5; trigger-send somekey123 192.168.0.2 9999;
```