select function as timeout?
struct timeval start,cur,timeout;
long duration;
timeout.tv_sec=0;
timeout.tv_usec = 555;
gettimeofday(&start,NULL);
select(0,NULL,NULL,NULL,&timeout);
gettimeofday(&cur,NULL);
duration = (cur.tv_sec-start.tv_sec)*1000000;
duration = duration + cur.tv_usec - start.tv_usec;
printf("%ld\n", duration);
Dont seems to get the correct time everytime i run it.
Run it ten time, only 2 times the value were near 555. Other 8 times were either too short or too long.
Anyone has any idea about this?
|