extract methods from main to UDPSocket lib