Fetch streams from UDP multicast address
I'm writing a program that receives the UDP streams that are sent to a multicast group address. Assume that I have an address like udp://249.0.0.1
. To this address, I receive two streams to two different ports, say 2500 and 2600. I need to write a C program that fetches both streams from the different port within a single program. Can you suggest a starting point (tutorials, use开发者_运维问答ful APIs, …)?
Create 2 UDP sockets, register both for multicast address.
You can fetch data either with:
- 2 processes (fork), blocking sockets.
- 2 threads (pthread), blocking sockets.
- 1 thread, non-blocking sockets. For the demultiplexing you need select, poll or epoll.
精彩评论