SocketAddress remoteAddress = null;
Throwable exception = null;
if (channel instanceof ScatteringByteChannel) {
try {
while (buf.writable()) {
int readBytes = buf.writeBytes((ScatteringByteChannel) channel, buf.writableBytes());
if (readBytes == 0) {
break;
} else if (readBytes < 0) {
closed = true;