How to receive the same udp-stream in several programs?

假如想象 提交于 2019-12-04 16:16:44

You should be able to use socat to forward unicast UDP to a multicast group, or just save data into a file and process later.

Edit 0:

Here is an example (this is on Linux - don't have any Windows boxes). Listen on unicast port 4242, forward to multicast 224.10.10.10:5252 (you might have to add ip-multicast-loop option if you are doing everything on the same machine):

~$ socat UDP-LISTEN:4242 UDP-DATAGRAM:224.10.10.10:5252

Receive on multicast (needs interface address or name), forwards to unicast 192.168.0.1:6666:

~$ socat UDP-RECVFROM:5252,ip-add-membership=224.10.10.10:eth0,reuseaddr,fork \
   UDP-DATAGRAM:192.168.0.1:6666

Run two of the above with different destination addresses (reuseaddr option allows these to be run on the same machine).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!