1

I have non-regularly running program which outputs string, I need to send this output to some kind of socket which can be distributed out of docker container and which can be listened by multiple listeners or even none.

I know standard FIFO named pipe but it expects to have one listener and notifier connected until that moment it stays blocked.

Is there way to obtain this type socket with "standard" linux commands or daemons? I am looking for solution with smallest number of dependencies, easily maintained...

EDIT:

i've found socat can work in this way, but i am unable to share mesagess to all clients.

shell1$ socat pipe:/tmp/test-in unix-listen:/tmp/test-out,fork
shell2$ socat - UNIX-CONNECT:/tmp/test-out
shell3$ socat - UNIX-CONNECT:/tmp/test-out
shell4$ echo "test" > socat - UNIX-CONNECT:/tmp/test-in

(shell2) test
user2216697
  • 121
  • 4

1 Answers1

1

Found solution at similar answer https://unix.stackexchange.com/questions/195880/socat-duplicate-stdin-to-each-connected-client. Socat seems can't work that way but ncat from nmap package does.

It works same for unix socket:

% mkfifo /tmp/messages-in
% exec 8<>/tmp/messages-in  # hold the fifo open
% ncat -l -U /tmp/messages-out -k --send-only < /tmp/messages-in

% echo "test" > /tmp/messages-in

% # every client connected to /tmp/messages-out will get "test" message
user2216697
  • 121
  • 4