teensyp.channel
A namespace of utility functions for interoperating with Java channels and streams.
->input-stream
(->input-stream ch)Convert an AsynchronousByteChannel into a blocking InputStream instance.
->output-stream
(->output-stream ch)Convert an AsynchronousByteChannel into a blocking OutputStream instance.
async-channel
(async-channel)Create a channel object satisfying the AsynchronousByteChannel interface. ByteBuffers written to this channel with the write method can be later read back with the read method.
Only one write and one read can be pending. Attempting to write or read from the channel when there are operations pending will result in a WritePendingException or ReadPendingException respectively.
When a buffer is passed to the write method, it is owned by the channel until it is fully read. This avoids the use of an intermediate buffer, but care needs to be taken around the reuse of buffers.
read
(read ch buf complete fail)Asynchronously read from an AsynchronousByteChannel, putting the result in buf, and calling either the complete or fail callback.
write
(write ch buf complete fail)Asynchronously write to an AsynchronousByteChannel, putting the result in buf, and calling either the complete or fail callback.