public interface Transport
I/O transport binding that handles asynchronous I/O operations for a
non-blocking NIO channel. A
Transport provides a selectable channel() on which to perform asynchronous I/O operations, along with an
readBuffer() into which input data will be read, and an writeBuffer() from which data will be written.
A Transport interfaces with the underlying asynchronous I/O system
via a TransportContext. The transport context invokes I/O callbacks
on the Transport when the underlying NIO channel is ready to perform
I/O operations permitted by the transport context's FlowControl.
-
Method Summary
Modifier and TypeMethodDescriptionchannel()Returns the NIO channel that thisTransportmanages.voiddidClose()Lifecycle callback invoked by the transport context after the underlying transport has closed.voidLifecycle callback invoked by the transport context when the underlying transport fails by throwing anerror.voidLifecycle callback invoked by the transport context after the underlying transport has timed out.voiddidWrite()I/O callback invoked by the transport context after the underlying transport has completed writing all data in itswriteBuffer, thereby completing the current write operation.voiddoAccept()I/O callback invoked by the transport context when the underlying transport is ready to complete an accept operation.voidI/O callback invoked by the transport context when the underlying transport is ready to complete a connect operation.voiddoRead()I/O callback invoked by the transport context asking thisTransportto read input data out of thereadBuffer, thereby completing a read operation from the underlying I/O transport.voiddoWrite()I/O callback invoked by the transport context asking thisTransportto write output data into thewriteBuffer, thereby initiating a write operation to the underlying I/O transport.longReturns the number of idle milliseconds after which thisTransportshould be closed due to inactivity.Returns the buffer into which input data should be read by the underlying I/O transport.voidsetTransportContext(TransportContext context) Sets the I/O transport context to which thisTransportis bound.Returns the I/O transport context to which thisTransportis bound; returnsnullif thisTransportis unbound.Returns the buffer from which output data should be written by the underlying I/O transport.
-
Method Details
-
transportContext
TransportContext transportContext()Returns the I/O transport context to which thisTransportis bound; returnsnullif thisTransportis unbound. -
setTransportContext
Sets the I/O transport context to which thisTransportis bound. -
channel
SelectableChannel channel()Returns the NIO channel that thisTransportmanages. -
readBuffer
ByteBuffer readBuffer()Returns the buffer into which input data should be read by the underlying I/O transport. -
writeBuffer
ByteBuffer writeBuffer()Returns the buffer from which output data should be written by the underlying I/O transport. -
idleTimeout
long idleTimeout()Returns the number of idle milliseconds after which thisTransportshould be closed due to inactivity. Returns-1if a default idle timeout should be used. Returns0if the underlying I/O transport should not time out. -
doAccept
I/O callback invoked by the transport context when the underlying transport is ready to complete an accept operation.- Throws:
IOException
-
doConnect
I/O callback invoked by the transport context when the underlying transport is ready to complete a connect operation.- Throws:
IOException
-
doRead
void doRead()I/O callback invoked by the transport context asking thisTransportto read input data out of thereadBuffer, thereby completing a read operation from the underlying I/O transport. May be invoked concurrently to other I/O callbacks, but never concurrently with otherdoReadcalls. -
doWrite
void doWrite()I/O callback invoked by the transport context asking thisTransportto write output data into thewriteBuffer, thereby initiating a write operation to the underlying I/O transport. May be invoked concurrently to other I/O callbacks, but never concurrently with otherdoWriteordidWritecalls. -
didWrite
void didWrite()I/O callback invoked by the transport context after the underlying transport has completed writing all data in itswriteBuffer, thereby completing the current write operation. May be invoked concurrently to other I/O callbacks, but never concurrently with otherdoWriteordidWritecalls. -
didTimeout
void didTimeout()Lifecycle callback invoked by the transport context after the underlying transport has timed out. The transport will automatically be closed. -
didClose
void didClose()Lifecycle callback invoked by the transport context after the underlying transport has closed. -
didFail
Lifecycle callback invoked by the transport context when the underlying transport fails by throwing anerror. The transport will automatically be closed.
-