DG> Hi,
DG> Back onto mailslots. I was doing what you said (get every 2nd message),
DG> and it worked. Until I sent two message together (ie, send one message
DG> then send another immediately after - no pause), and for the first
DG> message, it only sent it once. So this method doesn't work _all_ the
DG> time. So I came up with a better idea. When you send each message, add a
DG> packetnumber to the front. Then, when you receive a message, check if
DG> this packetnumber is >= the last packetnumber. If it is, discard the
DG> message. It's more complicated to implement, but at works all the time
DG> (as far as I can tell).
This should be what the packets on the network do already, but for some
reason don't. You could keep a circular buffer of the last few packets that
you received (sorta like the dupe checking ability of most echomail tossers).
The advantage of this is that you'll survive "overflow."
Say you use a single byte to store the packet number. Once you reach 255,
the next would be 256. However, overflow results in the packet number being
0 - which is less than the last packetnumber... resulting in the message
being discarded.
Of course, you could use four bytes - you'd have to reach 4.1 billion for it
to overflow. How often are these messages passed back and forth? Perhaps 4
billion may not "theoretically" be enough.
Another method is timestamping - but then you couldn't send more than one
message per smallest-time-interval-detectable (i.e., per clock tick,
generally, which means approximately 34ms). A combination of timestamp with
a single-byte packet number should do the trick - you probably couldn't send
more than 256 packets in 34ms anyway. (To be safe, a word packet number
would be more than sufficient for the next 20 years anyway )
--- Maximus/2 3.01
---------------
* Origin: Tanktalus' Tower BBS (PVT) (1:342/708)
|