add functions for converting time to/from timeval and timespec
fix select() to not wait longer than timeout with dropped packets
modify timeout in select() for time spent