Compare of (long) values returns true in error

I have two ethernet devices connected on a private network. To confirm that the connection between devices still exists, one sends a TCP/IP packet to the other every 2 seconds. The second unit sends back an acknowledge which resets the time out variable to MS_TIMER + time_out.

#define time_out 5000
long var;

When an acknowledge is received the following is set:
var = MS_TIMER + time_out; // var = 5 seconds from now

In the main loop I do a compare of MS_TIMER and the time out variable as here:

if ( (long)(MS_TIMER - var) > 0L ) {
// no response in over 5 seconds
// time out occurred
// reset port
}

However, after about anywhere from an hour to 3 hours the unit will reset even though var is greater than MS_TIMER. I confirmed this by doing a printf in debug mode of MS_TIMER and var.

If I change the code to:

if ( (int)(MS_TIMER - var) > 0 ) {
// no response in over 5 seconds
// time out occurred
// reset port
}

I will not get a reset until var is > MS_TIMER. ( a true time out )

Is this a bug or am I doing something wrong?

One unit uses an RCM3000 and the other uses an RCM3720.

Thanks,
Sam