timestamp

Hello,
i'm implementing an application that sends packet on a network. Now I'd like to discard the packet that are older than 2 minutes at the receiver.
I added to my packet a field (short) that include the time (UTC minute) when the packet was generated.

The receiver has its time:
SYSTEMTIME stR;
GetSystemTime(&stR);

so now I'd like to compare them:
if ((packet.minute + 2) < stR.wMinute))
{
printf("incorrect packet");
}

That's not enough: this is working fine till (packet.minute+2) != 0 so i have to consider that after the 59 the time is resetted to ZERO.
So..how can i solve that?

thanks
Try checking the in the condition not only minutes but also hours
the solution is really easy:

pseudo code:

diffTime = currentMinute - packet.minute;

if (diffTime > 2)
{
incorrect frame;
}
Topic archived. No new replies allowed.