code: public OutputStream asOutputStream() {
  		OutputStream out = new OutputStream() {
  
  			@Override
  			public final void write(int b) {
  				sendData(new byte[] { (byte) b });
  			}
  
  			@Override
  			public final void write(byte[] b) {
  				write(b, 0, b.length);
  			}
  
  			@Override
  			public final void write(byte[] b, int off, int len) {
  				byte[] copy = new byte[len];
  				System.arraycopy(b, 0, copy, 0, len);
  				sendData(copy);
  			}
  
  			@Override
  			public final void flush() {
  
  				// Do nothing
  			}
  
  			@Override
  			public final void close() {
  				sendClose();
  			}
  
  		};
  
  		// Bufferless/direct output
  		if (packetSize < 2) {
  			return out;
  		}
  
  		// Buffered output
  		return new BufferedOutputStream(out, packetSize);
  	}
docs: --- ACT AS OUTPUT STREAM ---