Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate input unix stream to multiple TCP clients (using socat)

Tags:

sockets

socat

I have a syslog server which writes to a unix stream /tmp/syslog.socket. I need to duplicate this stream to multiple TCP clients. Is there a way to achieve this using socat?

like image 550
Calin Don Avatar asked Oct 09 '22 21:10

Calin Don


1 Answers

I think I just accomplished this, especially the duplicating part, with the help of Some Helpful socat Commands.

socat TCP-LISTEN:4444,reuseaddr,fork SYSTEM:"tail -f ~/.tail-error-logs/*",pty

fork is important on the left side, pty is important on the right side.

What didn't work, was netcat style:

tail -f ~/.tail-error-logs/* | socat STDIO TCP-LISTEN:4444,fork,reuseaddr

It had the effect of output alternating between multiple attached clients, which is also documented on above website.

like image 127
lkraav Avatar answered Oct 13 '22 06:10

lkraav