| 2 | #include "udp.h" |
| 3 | |
| 4 | static double stamp_sub(const struct timeval *from, const struct timeval *sub_by) |
| 5 | { |
| 6 | struct timeval res; |
| 7 | |
| 8 | memcpy(&res, from, sizeof(struct timeval)); |
| 9 | |
| 10 | res.tv_usec -= sub_by->tv_usec; |
| 11 | if (res.tv_usec < 0) { |
| 12 | --res.tv_sec; |
| 13 | res.tv_usec += 1000000; |
| 14 | } |
| 15 | res.tv_sec -= sub_by->tv_sec; |
| 16 | |
| 17 | return res.tv_sec * 1000.0 + res.tv_usec/1000.0; |
| 18 | } |
| 19 | |
| 20 | static int sio(SOCK_UDP *sock, const char *data, int dlen, int count, |
| 21 | int inter, bool need_read) |