public class TCPNIOConnection extends NIOConnection
Connection implementation
for the TCPNIOTransport| Modifier and Type | Class and Description |
|---|---|
protected static interface |
TCPNIOConnection.ConnectResultHandler
This interface implementations can be used to be notified about the
TCPNIOConnection connect state.
|
Connection.CloseListener, Connection.CloseTypeattributes, channel, connectCloseSemaphorUpdater, isBlocking, isStandalone, maxAsyncWriteQueueSize, monitoringConfig, NOTIFICATION_CLOSED_COMPLETE, NOTIFICATION_INITIALIZED, processor, processorSelector, readTimeoutMillis, selectionKey, selectorRunner, transport, writeTimeoutMillis, zeroByteReadCount| Constructor and Description |
|---|
TCPNIOConnection(TCPNIOTransport transport,
SelectableChannel channel) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canWrite() |
boolean |
canWrite(int length)
Deprecated.
|
protected void |
checkConnectFailed(Throwable failure)
Method will be called in order to check if failure happened before
Connection was reported as connected. |
protected void |
enableInitialOpRead()
Enables OP_READ if it has never been enabled before.
|
SocketAddress |
getLocalAddress()
Returns the local address of this Connection,
or null if it is unconnected.
|
SocketAddress |
getPeerAddress()
Returns the address of the endpoint this Connection is
connected to, or null if it is unconnected.
|
int |
getReadBufferSize()
Get the default size of
Buffers, which will be allocated for
reading data from Connection. |
int |
getWriteBufferSize()
Get the default size of
Buffers, which will be allocated for
writing data to Connection. |
void |
notifyCanWrite(WriteHandler writeHandler)
Instructs the
OutputSink to invoke the provided
WriteHandler when it is possible to write more bytes (or characters). |
void |
notifyCanWrite(WriteHandler handler,
int length)
Deprecated.
|
protected boolean |
notifyReady() |
protected void |
onConnect()
Method will be called, when the connection gets connected.
|
protected void |
onRead(Buffer data,
int size)
Method will be called, when some data was read on the connection
|
protected void |
onWrite(Buffer data,
long size)
Method will be called, when some data was written on the connection
|
protected void |
preClose() |
protected void |
resetProperties() |
protected void |
setConnectResultHandler(TCPNIOConnection.ConnectResultHandler connectHandler) |
void |
setReadBufferSize(int readBufferSize)
Set the default size of
Buffers, which will be allocated for
reading data from Connection. |
protected void |
setSelectionKey(SelectionKey selectionKey) |
protected void |
setSelectorRunner(SelectorRunner selectorRunner) |
void |
setWriteBufferSize(int writeBufferSize)
Set the default size of
Buffers, which will be allocated for
writing data to Connection. |
protected void |
terminate0(CompletionHandler<Closeable> completionHandler,
CloseReason closeReason) |
String |
toString() |
addCloseListener, addCloseListener, assertOpen, attachToSelectorRunner, checkEmptyRead, close, close, closeFuture, closeGracefully0, closeSilently, closeWithReason, configureBlocking, configureStandalone, detachSelectorRunner, disableIOEvent, doClose, enableIOEvent, executeInEventThread, getAsyncReadQueue, getAsyncWriteQueue, getAttributes, getChannel, getCloseReason, getMaxAsyncWriteQueueSize, getMemoryManager, getMonitoringConfig, getProcessor, getProcessorSelector, getReadTimeout, getSelectionKey, getSelectorRunner, getTransport, getWriteTimeout, isBlocking, isClosed, isOpen, isStandalone, notifyConnectionError, notifyIOEventDisabled, notifyIOEventEnabled, notifyIOEventReady, notifyProbesAccept, notifyProbesBind, notifyProbesClose, notifyProbesConnect, notifyProbesError, notifyProbesRead, notifyProbesWrite, obtainProcessor, obtainProcessorState, read, read, removeCloseListener, removeCloseListener, setChannel, setMaxAsyncWriteQueueSize, setProcessor, setProcessorSelector, setReadTimeout, setWriteTimeout, simulateIOEvent, terminate, terminateSilently, terminateWithReason, write, write, write, write, writepublic TCPNIOConnection(TCPNIOTransport transport, SelectableChannel channel)
protected void setSelectionKey(SelectionKey selectionKey)
setSelectionKey in class NIOConnectionprotected void setSelectorRunner(SelectorRunner selectorRunner)
setSelectorRunner in class NIOConnectionprotected void preClose()
preClose in class NIOConnectionprotected boolean notifyReady()
public SocketAddress getPeerAddress()
public SocketAddress getLocalAddress()
protected void resetProperties()
public int getReadBufferSize()
Buffers, which will be allocated for
reading data from Connection.
The value less or equal to zero will be ignored.Buffers, which will be allocated for
reading data from Connection.public void setReadBufferSize(int readBufferSize)
Buffers, which will be allocated for
reading data from Connection.
The value less or equal to zero will be ignored.readBufferSize - the default size of Buffers, which will
be allocated for reading data from Connection.public int getWriteBufferSize()
Buffers, which will be allocated for
writing data to Connection.Buffers, which will be allocated for
writing data to Connection.public void setWriteBufferSize(int writeBufferSize)
Buffers, which will be allocated for
writing data to Connection.writeBufferSize - the default size of Buffers, which will
be allocated for writing data to Connection.protected final void setConnectResultHandler(TCPNIOConnection.ConnectResultHandler connectHandler)
protected final void onConnect()
throws IOException
IOExceptionprotected final void checkConnectFailed(Throwable failure)
Connection was reported as connected.protected void terminate0(CompletionHandler<Closeable> completionHandler, CloseReason closeReason)
terminate0 in class NIOConnectionprotected final void onRead(Buffer data, int size)
protected void enableInitialOpRead()
throws IOException
NIOConnectionenableInitialOpRead in class NIOConnectionIOExceptionprotected final void onWrite(Buffer data, long size)
public boolean canWrite()
true if a write to this OutputSink
will succeed, otherwise returns false.@Deprecated public boolean canWrite(int length)
length - specifies the number of bytes (or characters) that require writingtrue if a write to this OutputSink
will succeed, otherwise returns false.public void notifyCanWrite(WriteHandler writeHandler)
OutputSink to invoke the provided
WriteHandler when it is possible to write more bytes (or characters).
Note that once the WriteHandler has been notified, it will not
be considered for notification again at a later point in time.writeHandler - the WriteHandler that should be notified
when it's possible to write more data.@Deprecated public void notifyCanWrite(WriteHandler handler, int length)
OutputSink to invoke the provided
WriteHandler when it is possible to write length
bytes (or characters).
Note that once the WriteHandler has been notified, it will not
be considered for notification again at a later point in time.handler - the WriteHandler that should be notified
when it's possible to write length bytes.length - the number of bytes or characters that require writing.Copyright © 2016 Oracle Corporation. All Rights Reserved.