Re: AsyncUdpSocket: Receiving duplicate UDP Packet
Re: AsyncUdpSocket: Receiving duplicate UDP Packet
- Subject: Re: AsyncUdpSocket: Receiving duplicate UDP Packet
- From: Jens Alfke <email@hidden>
- Date: Fri, 14 May 2010 10:10:37 -0700
On May 12, 2010, at 7:35 PM, Todd Burch wrote:
I'm early in development, and all I'm doing is receiving a UDP
packet over a given port, and logging it to the console. However,
for some reason my UDP packet (transmitted from other software)
appears to be arriving twice!
The previous advice should solve the immediate problem. But be aware
that your code needs to be able to handle duplicate packets, as well
as dropped packets. Both are entirely possible due to the way IP
routing works. That's why it's called the Unreliable Datagram
Protocol :)
Both cases are fairly rare with modern networks, but they do happen,
and if your protocol doesn't deal with them, the result will be
intermittent and hard-to-reproduce failures.
The usual solution is to put a serial number in each packet. That way
the recipient can detect if it receives the same serial number twice
and ignore the second one. They're also useful for putting out-of-
order packets back in order — that's a likely scenario if the packets
are traveling a long distance since they might take different routes.
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden