• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Explain difference between TCP and UDP implementations of a chat program.

thornt

Lurker
hi guys, could you possibly help me to explain and contrast the two different connection implementations (TCP and UDP) for an Android chat program please. The main points that need explaining are:

 
good succint answer there Granite.

UDP doesn't have any error correction in the protocol. Programs that use it can have error correction, but its not in the protocol. UDP is basically shouting out and you don't care if someone heard you or not.

TCP has error correction, not needed in programs that use it because of this. TCP is more like a conversation.. You say a, b, and c, in sequence and the other end says the last thing I got in the sequence was b.. so you sart back over with c, d and e, and the other end says he got everything in sequence up to e, then you go f, g, and h.. ad nausium.
 
Just to add to the excellent advice already given, I would just say that a chat app probably should just use TCP as it's easier and more reliable.

The reason to choose UDP is for performance critical situations like streaming audio or multiplayer gaming, where sending the data as fast as possible is essential.
 
alostpacket, the consideration is different - in true streaming, if you lose a packet, there's not much you can do about it, so it doesn't pay to use a protocol designed to fill in missing packets. It would be something like shouting at a deaf person. For speed you use TCP, but something like a variable sliding window protocol (or something like like Zmodem, which got data through the most terrible connections with pretty good speed).
 
Back
Top Bottom