made stream read non blocking and read and write return amount of data processed