I have a single incoming video stream, and I'd like to set up multiple processes to handle it, each running at its own address. After some reading it seems socat is one way to do this

socat TCP4-LISTEN:1934,fork,reuseaddr TCP4:someaddress:1935 

This forwards everything to the target address, but it lets me bind one target only. Is there a way to bind multiple target addresses with socat? If I try multiple individual binds I get an "address already in use" error on subsequent binds. I'm not forced to use socat, anything that lets me copy my incoming stream is good, if anyone knows a better approach. Thanks.


Based on my earlier comments, I have just tested this solution[1] and it works as expected, if I understood your needs:

socat -u tcp4-listen:1934 - | tee >(socat - tcp4: >(socat - tcp4: > /dev/null

There must be processes already listening on 1935 and 1936 already before launching this otherwise the socat on the right will complain.

This is still a very brittle solution. I would advise trying alternative routes, like a temporary caching file or a pipe maybe.

[1] like that:

  • nc -l 1935 in a shell
  • nc -l 1936 in another shell
  • the command above in the third shell
  • and then in a fourth one: echo "foobar" | nc 1934
  • and I do see "foobar" in output in first and second shell.
  • Thanks for the help, I'm accepting this as it does answer my original question. But as you said, this whole thing feels brittle, and I think I need to come at this problem from a whole other angle. – Shukri Adams Feb 8 '18 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.