Younghyo Kim Younghyo Kim - 18 days ago 8
C# Question

What happens if udpclient lost packets in C#

I'm studying computer network nowadays. Now I know a big difference between TCP and UDP is that UDP can lose their packets while communication. I'm wondering how C# react with this lost. For example, one host sends

"ABCD\n"
string to another host. If there were the lost of packet, does the receiving host throw any
exception
or just got like
"AB\n"
? (addition) and i want to know some way to enforce for udpclient to lose their packet. then i can do experiment.

fvu fvu
Answer

C# couldn't care less - in fact it won't even know a packet was lost. Your code/logic may or may not have issues with that lost packet. That's entirely up to the logic you coded, and has nothing to do with the underlying programming language/runtime system.

I also think you're overthinking/overcomplicating this: losing a packet === not sending one...

Comments