Fixed UDP. Fixed read UDP vs. TCP reading and made it a more generalized function