I am streaming a file (a MP3) which starts playing on a client after 100KB has been received. I need perfect playback.
I have to fragment the file so it can be buffered on the client, so would it be best here to use UDP + some sort of custom reliable delivery protocol? (Assuming I keep the datagrams small ~1400bytes)
Or should I just use TCP? If TCP - what size should I fragment the file to for best performance - I assume it will be related to the size of a TCP packet?
I read somewhere that the/a reason to use TCP instead of UDP + reliability protocol is that TCP does some fancy stuff managing/sharing the bandwidth with other applications whereas UDP is greedy. Is this true? If so, if I did decide to use UDP, would it mean that if I am streaming to several clients at o开发者_如何转开发nce I would have to include some fancy algorithms to share the bandwidth?
would it be best here to use UDP + some sort of custom reliable delivery protocol?
Don't try to reinvent TCP. It's likely better than anything you could cook up yourself.
Or should I just use TCP? If TCP - what size should I fragment the file to for best performance - I assume it will be related to the size of a TCP packet?
There's no need to split the file up at all with TCP -- it's a stream-based protocol, after all. Just start sending it all down the connection, and you'll receive the MP3 data as it arrives.
精彩评论