admin管理员组文章数量:1201569
I have 2 host that is part of one IP network 192.168.1.0/24. Let's say one of them is host A with IP address 192.168.1.1 and other host is B with IP address 192.168.1.2.
I have an application that generates UDP stream on host B and send it to 192.168.1.1:12345. Now I want to N separate processes running on host A to be able to receive this stream simultaneously. How can I do it?
I have 2 host that is part of one IP network 192.168.1.0/24. Let's say one of them is host A with IP address 192.168.1.1 and other host is B with IP address 192.168.1.2.
I have an application that generates UDP stream on host B and send it to 192.168.1.1:12345. Now I want to N separate processes running on host A to be able to receive this stream simultaneously. How can I do it?
Share Improve this question asked Jan 22 at 11:38 Kamil ZaripovKamil Zaripov 98012 silver badges39 bronze badges 1 |1 Answer
Reset to default 2You can use multicast. Modify your application to send UDP packets to some multicast group address (e.g. 239.255.0.1:12). Any number of processes can subscribe to that group and receive the data. It might might require enabling IGMP on your network.
Other option is to use proxy.
本文标签: network programmingReceive one UDP stream with 2 applicationsStack Overflow
版权声明:本文标题:network programming - Receive one UDP stream with 2 applications - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738567088a2100363.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
fork
new processes which reads from the socket and processes the messages. But please note that you don't have control over which process gets which message. And once a message is read, you can not put it back to be read by another process. Instead I suggest you have one program which receives all messages, and then distributes it to the actual processes that are supposed to process the data. Using local sockets (AF_LOCAL
) you can use the normal socket API in the other processes. – Some programmer dude Commented Jan 22 at 11:47