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.CloseType
asyncReadQueue, asyncWriteQueue, attributes, channel, closeTypeFlag, connectCloseSemaphor, 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 |
close0(CompletionHandler<Closeable> completionHandler,
boolean isClosedLocally) |
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
Buffer s, which will be allocated for
reading data from Connection . |
int |
getWriteBufferSize()
Get the default size of
Buffer s, 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
Buffer s, 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
Buffer s, which will be allocated for
writing data to Connection . |
String |
toString() |
addCloseListener, addCloseListener, attachToSelectorRunner, checkEmptyRead, close, close, closeSilently, configureBlocking, configureStandalone, detachSelectorRunner, disableIOEvent, enableIOEvent, getAsyncReadQueue, getAsyncWriteQueue, getAttributes, getChannel, getMaxAsyncWriteQueueSize, getMonitoringConfig, getProcessor, getProcessorSelector, getReadTimeout, getSelectionKey, getSelectorRunner, getTransport, getWriteTimeout, isBlocking, 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, write, write, write, write, write
public TCPNIOConnection(TCPNIOTransport transport, SelectableChannel channel)
protected void setSelectionKey(SelectionKey selectionKey)
setSelectionKey
in class NIOConnection
protected void setSelectorRunner(SelectorRunner selectorRunner)
setSelectorRunner
in class NIOConnection
protected void preClose()
preClose
in class NIOConnection
protected boolean notifyReady()
public SocketAddress getPeerAddress()
public SocketAddress getLocalAddress()
protected void resetProperties()
public int getReadBufferSize()
Buffer
s, which will be allocated for
reading data from Connection
.
The value less or equal to zero will be ignored.Buffer
s, which will be allocated for
reading data from Connection
.public void setReadBufferSize(int readBufferSize)
Buffer
s, which will be allocated for
reading data from Connection
.
The value less or equal to zero will be ignored.readBufferSize
- the default size of Buffer
s, which will
be allocated for reading data from Connection
.public int getWriteBufferSize()
Buffer
s, which will be allocated for
writing data to Connection
.Buffer
s, which will be allocated for
writing data to Connection
.public void setWriteBufferSize(int writeBufferSize)
Buffer
s, which will be allocated for
writing data to Connection
.writeBufferSize
- the default size of Buffer
s, which will
be allocated for writing data to Connection
.protected final void setConnectResultHandler(TCPNIOConnection.ConnectResultHandler connectHandler)
protected final void onConnect() throws IOException
IOException
protected final void checkConnectFailed(Throwable failure)
Connection
was reported as connected.IOException
protected void close0(CompletionHandler<Closeable> completionHandler, boolean isClosedLocally)
close0
in class NIOConnection
protected final void onRead(Buffer data, int size)
protected 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 © 2014 Oracle Corporation. All rights reserved.