Is it worth trying building my own reliability on top of UDP? Or should I just opt for TCP?

By : Jim
Source: Stackoverflow.com
Question!

I have never tried to program on top of UDP but I know that it is fast and unreliable.
My question is if I program the reliability on top of UDP would the resulting performance make it the same as using TCP? I.e. is it worth to try?
Key point: Haven't programmed in UDP and will try to implement reliability for the first time.

By : Jim


Answers

TCP is going to be easier to implement and more reliable in the long run. UDP might be viable if you're looking ahead into a HUGE project, but simple TCP design might likely be up to even a large task.



Another thing to consider is that TCP also introduces its own latency due to adjustment of sending rate -- a property also known as congestion control. Congestion control manifests in terms of slow start, addition increase, and multiplicative decrease of TCP window. This property is in addition to reliability offered by TCP. One of the reasons why UDP (or one of its variants) is popularly used for audio/video is that it has no latency due to congestion control and retransmission. So, if you are application is latency sensitive, then going along with UDP coupled with minimal reliability would certainly be better.



If the choices are 'craft some reliability into UDP' or 'go with a proven option like TCP', I would definitely go the TCP route. Is there a reason you're looking to avoid TCP? I'm thinking this reasoning could be critical to recommendations made.

There is a similar thread on this that mentions a number of options aside from UDP/TCP you might consider using before implementing something custom. Check it out here: What do you use when you need reliable UDP?

By : Nizzo


This video can help you solving your question :)
By: admin