snipplets.dev/code/Bash/unix-socket-server.sh

20 lines
338 B
Bash
Raw Normal View History

2023-06-18 22:04:38 +03:00
#!/bin/bash
2023-09-10 01:13:40 +03:00
# TODO: Добавить описание и пример работы
2023-06-18 22:04:38 +03:00
# TCP
2023-08-16 22:01:02 +03:00
# coproc nc -l localhost 3000
2023-06-18 22:04:38 +03:00
# UnixSocket
coproc nc -l -U ./app.sock
while read -r cmd; do
2023-08-16 22:01:02 +03:00
case $cmd in
d) date ;;
q) break ;;
*) echo 'Try again?'
esac
2023-06-18 22:04:38 +03:00
done <&"${COPROC[0]}" >&"${COPROC[1]}"
kill "$COPROC_PID"