I have a problem with receiving UDP packets. My environment is running Android 2.1 on ARMv7. With C socket programming, I use recvmsg to receive packets from kernel but occasionally there are some packet loss events. The sender and receiver are in the same LAN so it’s no doubt that packets shouldn’t lose. And I proved it via Wireshark.
However, after I replaced recvmsg with recvfrom to receive packets, packet loss event didn’t occur anymore.
I’m sure the return value of recvmsg is always more than 0, meaning no error happens.
Is it possible that some packets are dropped in kernel-space only when using recvmsg ?
Yes, it’s possible. UDP is unreliable. If dropping of UDP datagrams is creating a problem, then something is very wrong with your design.