Fix a bug in data transfer.

For maximized throughput, try sending until buffer is full. Data is
cached and wait till the buffer is resumed.