For a reliable connection you have to use TCP.
However, I would like to know if there is a way to modify my code so that I can check for lost packets in UDP