In order to decrease the byte-copying needed with non-blocking socket channels, I figured I could just write my own "PipeBuffer" that provides an InputByteBuffer- and OutputByteBuffer-view of the same underlying ByteBuffer. That buffer would be treated as a cyclic buffer
This would allow the client and server to just keep any unsent data from a SocketChannel.write() call to stay in the buffer without having to allocate a new buffer or move the remaining bytes to the start of the buffer.
Unfortunately, the constructor of ByteBuffer is package private, so that made me thing I'm probably attempting to do something I shouldn't.
Does anyone have any better suggestions?