how to implement timeouts for IO operations?