public class SocketConnection extends java.lang.Object implements SocketHandler
SocketHandler using a standard socket.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed |
protected SshEngine |
daemon |
protected SshEngineContext |
daemonContext |
protected java.nio.channels.SelectionKey |
key |
protected ProtocolEngine |
protocolEngine |
protected SelectorThread |
selectorThread |
protected java.nio.channels.SocketChannel |
socketChannel |
protected java.nio.ByteBuffer |
socketDataIn |
protected java.nio.ByteBuffer |
socketDataOut |
| Constructor and Description |
|---|
SocketConnection()
Construct the socket.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTask(ConnectionAwareTask task)
Add a task to the executor
|
void |
closeConnection()
Close this socket connection.
|
void |
closeConnection(boolean closeProtocol) |
void |
flagWrite() |
Connection<? extends SshContext> |
getConnection()
Get the Connection for this handler
|
SshContext |
getContext()
Get the current context
|
SshEngineContext |
getDaemonContext()
Get the daemon process for this socket.
|
IdleStateManager |
getIdleStates()
Get the idle state manager.
|
int |
getInitialOps()
Get the initial interested ops for this socket.
|
java.net.SocketAddress |
getLocalAddress()
Returns the local address to which the remote socket is connected.
|
int |
getLocalPort()
Returns the local port to which the remote socket is connected.
|
java.lang.String |
getName()
A name for this Socket
|
int |
getPort()
Returns the local port to which the remote socket is connected.
|
ProtocolEngine |
getProtocolEngine()
Get the protocol engine for this socket.
|
java.net.SocketAddress |
getRemoteAddress()
Returns the address of the remote socket.
|
SelectorThread |
getSelectorThread()
Get the selector thread this handler is connected to.
|
java.nio.channels.SocketChannel |
getSocketChannel()
Get the SocketChannel for this socket.
|
SelectorThread |
getThread()
Get the selector thread for this connection
|
void |
initialize(ProtocolEngine protocolEngine,
SshEngine daemon,
java.nio.channels.SelectableChannel channel)
Initialize the socket with the protocol engine and the daemon process.
|
protected boolean |
isConnected()
Is the socket still connected?
|
boolean |
isSelectorThread()
Is the current thread this sockets
SelectorThread? |
boolean |
processReadEvent()
The selector is ready to be read.
|
boolean |
processWriteEvent()
The selector is ready to be written to.
|
void |
registrationCompleted(java.nio.channels.SelectableChannel channel,
java.nio.channels.SelectionKey key,
SelectorThread selectorThread)
The sockets channel has completed registration.
|
void |
setProtocolEngine(ProtocolEngine protocolEngine)
Set a new ProtocolEngine to handle this sockets data.
|
void |
setSelectionKey(java.nio.channels.SelectionKey key) |
void |
setThread(SelectorThread thread)
Set the selector thread for this connection
|
boolean |
wantsRead()
Tell the selector that the handler wants to read.
|
boolean |
wantsWrite()
Tell the selector that the handler wants to write.
|
protected java.nio.channels.SocketChannel socketChannel
protected ProtocolEngine protocolEngine
protected SshEngineContext daemonContext
protected SelectorThread selectorThread
protected java.nio.channels.SelectionKey key
protected SshEngine daemon
protected java.nio.ByteBuffer socketDataIn
protected java.nio.ByteBuffer socketDataOut
protected boolean closed
public void initialize(ProtocolEngine protocolEngine, SshEngine daemon, java.nio.channels.SelectableChannel channel) throws java.io.IOException
initialize in interface SocketHandlerprotocolEngine - ProtocolEnginedaemon - Daemonjava.io.IOExceptionpublic void registrationCompleted(java.nio.channels.SelectableChannel channel,
java.nio.channels.SelectionKey key,
SelectorThread selectorThread)
throws java.io.IOException
registrationCompleted in interface SelectorRegistrationListenerchannel - SelectableChannelkey - SelectionKeyselectorThread - SelectorThreadjava.io.IOExceptionpublic void setSelectionKey(java.nio.channels.SelectionKey key)
setSelectionKey in interface SelectionKeyAwarepublic void setProtocolEngine(ProtocolEngine protocolEngine)
protocolEngine - public void closeConnection()
public void closeConnection(boolean closeProtocol)
public ProtocolEngine getProtocolEngine()
public SshEngineContext getDaemonContext()
public java.net.SocketAddress getLocalAddress()
public int getLocalPort()
public int getPort()
public java.net.SocketAddress getRemoteAddress()
public java.nio.channels.SocketChannel getSocketChannel()
public IdleStateManager getIdleStates()
public boolean isSelectorThread()
SelectorThread?protected boolean isConnected()
public SelectorThread getThread()
public int getInitialOps()
getInitialOps in interface SocketHandlerpublic boolean processReadEvent()
processReadEvent in interface SocketHandlerpublic boolean processWriteEvent()
processWriteEvent in interface SocketHandlerpublic void setThread(SelectorThread thread)
setThread in interface SocketHandlerthread - SelectorThreadpublic void addTask(ConnectionAwareTask task)
SocketHandleraddTask in interface SocketHandlerpublic boolean wantsWrite()
SocketHandlerwantsWrite in interface SocketHandlerpublic SelectorThread getSelectorThread()
SocketHandlergetSelectorThread in interface SocketHandlerpublic void flagWrite()
public java.lang.String getName()
SocketHandlergetName in interface SocketHandlerpublic SshContext getContext()
SocketHandlergetContext in interface SocketHandlerpublic Connection<? extends SshContext> getConnection()
SocketHandlergetConnection in interface SocketHandlerpublic boolean wantsRead()
SocketHandlerwantsRead in interface SocketHandlerCopyright © 2021. All rights reserved.