Fix error handling when setting up the UDP socket.