Reputation: 168
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 ?
Upvotes: 0
Views: 2206
Reputation: 251
This recv man page seems to indicate that recvmsg does not block, while recvfrom does block, at least by default. It's possible that you are calling recvmsg and there are no packets available at that moment. If you called it repeatedly I suppose you might see all your packets eventually just like you did in wireshark.
Upvotes: -1
Reputation: 182827
Yes, it's possible. UDP is unreliable. If dropping of UDP datagrams is creating a problem, then something is very wrong with your design.
Upvotes: 2