public abstract class AbstractDataChannel extends Object implements DataChannel
DataChannel.CloseAsyncStatus, DataChannel.FlushStatus| Modifier and Type | Field and Description |
|---|---|
protected boolean |
configuredBlocking
The cached value of whether the channel is blocking.
|
protected SocketChannel |
socketChannel
The underlying socket channel
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractDataChannel(SocketChannel socketChannel)
Constructor for sub-classes.
|
| Modifier and Type | Method and Description |
|---|---|
void |
configureBlocking(boolean block)
Configures the channel to be blocking.
|
protected void |
ensureCloseAsyncForNonBlocking()
Ensures this channel is in non-blocking mode when calling closeAsync.
|
protected void |
ensureCloseForBlocking()
Ensures this channel is in blocking mode when calling close.
|
SocketAddress |
getRemoteAddress()
Returns the remote address to which this channel's socket is connected.
|
SocketChannel |
getSocketChannel()
Accessor for the underlying SocketChannel.
|
boolean |
isBlocking()
Tells whether or not every I/O operation on this channel will block
until it completes.
|
boolean |
isConnected()
Checks whether the channel is connected.
|
Socket |
socket()
Retrieves a socket associated with this channel.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, closeAsync, closeForcefully, flush, isSecure, isTrustCapable, isTrusted, read, writewritewritereadreadprotected boolean configuredBlocking
AbstractSelectableChannel.isBlocking() acquires the AbstractSelectableChannel.blockingLock(). Some socket read operations also acquires
such lock, e.g., sun.nio.ch.ChannelInputStream#read. Thus a non-blocking
implementation calling isBlocking() might be blocked by concurrent
operations. Use a cached value to avoid such blocking behavior.
Accessors to this field must synchronize on the object.protected final SocketChannel socketChannel
protected AbstractDataChannel(SocketChannel socketChannel)
socketChannel - The underlying SocketChannel over which data will
be sent. This should be the lowest-level socket so that select
operations can be performed on it.public boolean isConnected()
isConnected in interface DataChanneltrue if the channel is connectedpublic Socket socket()
socket in interface DataChannelpublic SocketAddress getRemoteAddress() throws IOException
getRemoteAddress in interface DataChannelIOExceptionpublic void configureBlocking(boolean block)
throws IOException
configureBlocking in interface DataChannelIOExceptionpublic boolean isBlocking()
isBlocking in interface DataChannelpublic SocketChannel getSocketChannel()
getSocketChannel in interface DataChannelprotected void ensureCloseForBlocking()
protected void ensureCloseAsyncForNonBlocking()
Copyright © 2024. All rights reserved.