Implementing function to send data to a UDP socket