Improve timeout management to use native stream_select function