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

18 lines
249 B
Bash
Raw Normal View History

2023-06-18 22:04:38 +03:00
#!/bin/bash
# TCP
#coproc nc -l localhost 3000
# UnixSocket
coproc nc -l -U ./app.sock
while read -r cmd; do
case $cmd in
d) date ;;
q) break ;;
*) echo 'Try again?'
esac
done <&"${COPROC[0]}" >&"${COPROC[1]}"
kill "$COPROC_PID"