rewritten readbuffer
added TIMEOUTTIME for timeout time