fixed for nonblocking write to respect timeout
fixed for nonblock write patch - read-forever-loop