aboutsip / pkts

Pure java based pcap library capable of reading and writing to/from pcaps.
Other
196 stars 91 forks source link

Experiment: ChannelBuffer to stream from Channels without wrapping them as InputStreams #77

Closed epall closed 5 years ago

epall commented 6 years ago

In my current project I'm working with an input source that presents a java.nio.SeekableByteChannel, so I figured I'd try skipping the layer of Channels.newInputStream() and write a Buffer implementation that worked directly with ReadableByteChannel. This turned out to be pretty simple after I refactored the common behavior (almost everything, as it turns out) from BoundedInputStreamBuffer into a superclass, StreamingBuffer.

This turned out to not have any measurable performance impact, so I'm inclined to abandon it. If you think it'd be useful, though, I'm happy to add some tests and get it through code review.