function _timeoutfgets optimization