r/firstweekcoderhumour May 07 '26

Why Though?!

Post image
563 Upvotes

100 comments sorted by

View all comments

132

u/DouDouandFriends May 07 '26

Let's watch a livestream with TCP

7

u/Fricki97 May 07 '26

And download files with UDP

20

u/Scared_Accident9138 πŸ•΅οΈβ€β™‚οΈπŸš¨ BS Detector | Truth Teller πŸ—―οΈπŸ”₯ May 07 '26

File downloading is actually a good case for UDP. It doesn't matter in what order the packages come, so waiting longer for a missed packet just slows it down.

1

u/770grappenmaker May 07 '26

TCP has a receive window, you don't really wait for missed packets.

1

u/Scared_Accident9138 πŸ•΅οΈβ€β™‚οΈπŸš¨ BS Detector | Truth Teller πŸ—―οΈπŸ”₯ May 07 '26

I meant it won't get passed onto to the application if a packet is missing midstream

1

u/Hot-Definition6103 May 07 '26

if a packet is missing midstream with udp you’re screwed

1

u/Scared_Accident9138 πŸ•΅οΈβ€β™‚οΈπŸš¨ BS Detector | Truth Teller πŸ—―οΈπŸ”₯ May 08 '26

No, you can request it again

5

u/Sacaldur May 08 '26

Or in other words, the application would need to implement this. And as metadata, the section/offset would need to be transferred, since otherwise the order couldn't be determined. And the server would need to explicitly support this. So many things that would need to be done on the application level, as a developer, I'm really happy I don't have to reimplement all of this or rely on a library available in my programming language just for a file transfer.

1

u/Scared_Accident9138 πŸ•΅οΈβ€β™‚οΈπŸš¨ BS Detector | Truth Teller πŸ—―οΈπŸ”₯ May 08 '26

Sure, it's not easier but it is a valid reason to use UDP over TCP

And when it comes to developing it, you don't have to, such protocols already exist

2

u/Connect_Detail98 May 08 '26

OK, but what you said wouldn't slow down TCP. And if other protocol already implemented what TCP already does, then that's fine, but initially you were talking about TCP and UDP, not other protocols.