You'll only lose data with recvfrom if your buffer is too small.
You can avoid having a too small buffer by calling recvfrom with MSG_PEEK argument to check the required buffer size without removing any data from the queue (you can read how to do this
here[
^]).