Fix hanging network thread due to timing calculation errors in UDP network class.

GetNextTick() may sometimes return a tick in the past, which calculations need to consider.

This might also fix #1076.