sockets - How do I compare two timestamps in C? -


I am writing a socket program that keeps the fifa queue for two input sockets. While deciding the queue for the service, the program draws the most recent timetable from each queue.

I need a reliable method to compare two timetable structs. I tried to use timercmp () , but my version of GCC does not support it, and the documentation says that the function is not compatible with POSIX.

What should I do?

Googling Timetable From that page:

< P> It is often necessary to subtract two types of Type Strait timewak or Structure Timespack. The best way to do this is to do this also on some strange operating systems where TV_SC member has an unsigned type.

  / * Due to the 'straight time' values, decrease x and y, store the result in RESULT. If negative is negative, otherwise return to 0 * / Int timewell_subtract (result, x, y) structure timel * results, * x, * y; Continue updating * / If (x-> tv_usec>  TV_Usek) after updating {/}> {int nsec = (y-> tv_usec - x-> tv_usec) / 1000000 + 1; Y-> gt_usec - = 1000000 * nsec; Y-> TV_SC + = NSEC; } If (x-> TV_Usek - y-> gt_usec & gt; 1000000) {int nsec = (x-> tv_usec - y-> tv_usec) / 1000000; Y-> gt_usec + = 1000000 * nsec; Y-> gt_sec - = nsec; } / * Calculate the remaining time to wait Tv_usec is definitely positive * / result-> TV_SC = x- & gt; TV_SC - Wi-> TV_SC; Results-> Tv_usec = x- & gt; Tv_usec - y-> Tv_usec; / * Return 1 if the result is negative * / return x-> TV_SC & lt; Y-> Tv_sec; }  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -