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 thisTransport
manages.void
didClose()
Lifecycle callback invoked by the transport context after the underlying transport has closed.void
Lifecycle callback invoked by the transport context when the underlying transport fails by throwing anerror
.void
Lifecycle callback invoked by the transport context after the underlying transport has timed out.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.void
doAccept()
I/O callback invoked by the transport context when the underlying transport is ready to complete an accept operation.void
I/O callback invoked by the transport context when the underlying transport is ready to complete a connect operation.void
doRead()
I/O callback invoked by the transport context asking thisTransport
to read input data out of thereadBuffer
, thereby completing a read operation from the underlying I/O transport.void
doWrite()
I/O callback invoked by the transport context asking thisTransport
to write output data into thewriteBuffer
, thereby initiating a write operation to the underlying I/O transport.long
Returns the number of idle milliseconds after which thisTransport
should be closed due to inactivity.Returns the buffer into which input data should be read by the underlying I/O transport.void
setTransportContext
(TransportContext context) Sets the I/O transport context to which thisTransport
is bound.Returns the I/O transport context to which thisTransport
is bound; returnsnull
if thisTransport
is 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 thisTransport
is bound; returnsnull
if thisTransport
is unbound. -
setTransportContext
Sets the I/O transport context to which thisTransport
is bound. -
channel
SelectableChannel channel()Returns the NIO channel that thisTransport
manages. -
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 thisTransport
should be closed due to inactivity. Returns-1
if a default idle timeout should be used. Returns0
if 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 thisTransport
to 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 otherdoRead
calls. -
doWrite
void doWrite()I/O callback invoked by the transport context asking thisTransport
to 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 otherdoWrite
ordidWrite
calls. -
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 otherdoWrite
ordidWrite
calls. -
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.
-