code: public WritableByteChannel asWritableByteChannel() {
  
  		// Bufferless/direct output
  		if (packetSize < 2) {
  			return new WritableByteChannel() {
  
  				@Override
  				public final boolean isOpen() {
  					return !closed.get();
  				}
  
  				@Override
  				public final void close() {
  					sendClose();
  				}
  
  				@Override
  				public final int write(ByteBuffer src) {
  					try {
  						int len = src.remaining();
  						if (len > 0) {
  							byte[] packet = new byte[len];
  							src.get(packet);
  							sendData(packet);
  						}
  						return len;
  					} catch (Throwable cause) {
  						try {
  							sendError(cause);
  						} catch (Throwable ignored) {
  						}
  						throw cause;
  					}
  				}
  
  				@Override
  				protected final void finalize() throws Throwable {
  					close();
  				}
  
  			};
  		}
  
  		// Buffered output
  		final OutputStream out = asOutputStream();
  		return new WritableByteChannel() {
  
  			@Override
  			public final boolean isOpen() {
  				return !closed.get();
  			}
  
  			@Override
  			public final void close() throws IOException {
  				out.flush();
  				out.close();
  			}
  
  			@Override
  			public final int write(ByteBuffer src) throws IOException {
  				try {
  					int len = src.remaining();
  					if (len > 0) {
  						byte[] packet = new byte[len];
  						src.get(packet);
  						out.write(packet);
  					}
  					return len;
  				} catch (Throwable cause) {
  					try {
  						sendError(cause);
  					} catch (Throwable ignored) {
  					}
  					throw cause;
  				}
  			}
  
  		};
  	}
docs: --- ACT AS BYTE CHANNEL ---