Ok, I think at least I got something with socat
- namely, the option fork
needs to be appended to the server line:
$ socat - udp4-listen:5000,reuseaddr,fork
... and then, in another terminal, we can call echo
piping into socat
client line multiple times on command line, as it will exit immediately (well, after half a second :)):
$ echo "hello" | socat - udp-sendto:127.0.0.1:5000
$ echo "hello" | socat - udp-sendto:127.0.0.1:5000
$ echo "hello" | socat - udp-sendto:127.0.0.1:5000
... and going back to the first terminal, we can see that the server has successfully shown all three hello
s:
$ socat - udp4-listen:5000,reuseaddr,fork
hello
hello
hello
^C
Note that even with a fork
-ed socat
server, the line echo "hello" | nc -u 127.0.0.1 5000
will still 'lock' as if waiting for user input; however, now after Ctrl-C and re-running the command, i.e.
$ echo "hello" | nc -u 127.0.0.1 5000
^C
$ echo "hello" | nc -u 127.0.0.1 5000
^C
$ echo "hello" | nc -u 127.0.0.1 5000
^C
... the fork
-ed socat
server will show three hello
s without the need to be restarted..
Seemingly, this openBSD netcat
doesn't have a fork
option - but I'm not sure if it has one that is corresponding to it..
Anyways, hope this helps someone,
Cheers!
Try this:
sudo socat -ddd -ddd PTY,raw,echo=0 "EXEC:'python /tmp/echo.py',pty,raw,echo=0"
(for some reason it didn't like me specifying the link= but the above provided /dev/pts/6
so I ran:
$ sudo python pyserial1.py
4
1
1
8
...
Best Answer
This comes straight from the Wikipedia page on netcat. In Term3, you would run:
This does pretty much exactly what you want. It uses a FIFO to get output from the left-hand side back into the right-hand side. It's not, strictly speaking, a temporary file -- a FIFO is a named pipe between two processes.