Real-Time Data Streaming to Multiple Clients
I would like to write an application which will stream data at 2400 baud over the internet from a server to multiple clients. The data will be the same for each client, and it would probably be fine to send it as a UDP stream, since exact data accuracy is not a 100% necessity, as there are checksums built-in to the data format and the data will be sent repeatedly on a loop.
What is the best way to do this? I would want to write the server in C, but I don't know how to best multicast this data to the different clients that would be receiving it all over the country.
I'm sure this seems like a pretty draconian way to go about my project, as opposed to just 开发者_StackOverflow社区using some sort of fetch command, but I'd prefer to do it this way if possible.
You may wish to take a look at unicast for this, particularly if your clients are on multiple directories. You should be able to send TCP or UDP traffic out with your data to each of your clients, particularly if bandwidth needs are small. IP multicast works best to groups of nodes on networks near each other.
Loop over client addresses repeatedly, and send your data. Moderate the rate at which you loop to limit the data rate.
Pay attention to the reliability issue: correctness is not the only problem with UDP; you also have no acknowledgment that your data was received, and no guarantee on ordering.
Baud doesn't really apply here, as the data is segmented into more or less discrete chunks.
精彩评论