问题原文
原帖链接 · Shukri Adams · CC BY-SA 3.0
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.
已采纳解答
原帖链接 · Patrick Mevzek · CC BY-SA 3.0
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:127.0.0.1:1935) >(socat - tcp4:127.0.0.1:1936) > /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 127.0.0.1 1935in a shellnc -l 127.0.0.1 1936in another shell- the command above in the third shell
- and then in a fourth one:
echo "foobar" | nc 127.0.0.1 1934 - and I do see "foobar" in output in first and second shell.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
