Search code examples
javahttpnettyniozero-copy

is there transferFrom like functionality in Netty for zero copy?


I'm developing a Http server that processes fairly large size of payloads. Since Netty provide zero-copy, I thought of using zero-coping of the payload using Netty's zero-copy. But it seems Netty only provide transferTo(WritableByteChannel target, long position) but not providing transferFrom() like method to read the content directly in to a file.

Is that just the way it is or are there any workarounds? thanks.


Solution

  • Netty 4.0.28+ provides splice support when using the native epoll transport. After proper setup, channel.spliceTo(fileDescriptor, 0, data.length); call in your handler will do the trick. Note that this only works on Linux.