-
public interface Transport
I/O transport binding that handles asynchronous I/O operations for a non-blocking NIO channel. ATransport
provides a selectablechannel()
on which to perform asynchronous I/O operations, along with anreadBuffer()
into which input data will be read, and anwriteBuffer()
from which data will be written.A
Transport
interfaces with the underlying asynchronous I/O system via aTransportContext
. The transport context invokes I/O callbacks on theTransport
when the underlying NIO channel is ready to perform I/O operations permitted by the transport context'sFlowControl
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SelectableChannel
channel()
Returns the NIO channel that thisTransport
manages.void
didClose()
Lifecycle callback invoked by the transport context after the underlying transport has closed.void
didFail(Throwable error)
Lifecycle callback invoked by the transport context when the underlying transport fails by throwing anerror
.void
didTimeout()
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
doConnect()
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
idleTimeout()
Returns the number of idle milliseconds after which thisTransport
should be closed due to inactivity.ByteBuffer
readBuffer()
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.TransportContext
transportContext()
Returns the I/O transport context to which thisTransport
is bound; returnsnull
if thisTransport
is unbound.ByteBuffer
writeBuffer()
Returns the buffer from which output data should be written by the underlying I/O transport.
-
-
-
Method Detail
-
transportContext
TransportContext transportContext()
Returns the I/O transport context to which thisTransport
is bound; returnsnull
if thisTransport
is unbound.
-
setTransportContext
void setTransportContext(TransportContext context)
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
void doAccept() throws IOException
I/O callback invoked by the transport context when the underlying transport is ready to complete an accept operation.- Throws:
IOException
-
doConnect
void doConnect() throws IOException
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
void didFail(Throwable error)
Lifecycle callback invoked by the transport context when the underlying transport fails by throwing anerror
. The transport will automatically be closed.
-
-