在 看协议的过程中经常会有同步 时间计算获得时间延迟,所以会用到timeval
/*
* Structure used in select() call, taken from the BSD file sys/time.h.
*/
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
tv_sec 代表多少秒
tv_usec 代表多少微秒 1000000 微秒 = 1秒
上面taken from the BSD file sys/time.h 直接用函数 gettimeofday 就可以获得时间