The question is a bit vague. What are you try to check?
- If you want to know whether the UDP socket is created successfully, then check the return code from new() is good enough. If it succeeds, it means that a local port has been picked, and a UDP socket is created.
- If you want to check whether you can actually send packet, then send a packet, and see whether the peer receives it. If you want to see whether, it can receive, then let the peer send something.
No magic here. By the way, UDP does not gurantee successful delivery, so even the packet is not received on either side, does not neccessarily to indicate a problem in your code.