public class SocketConnection extends Object implements SocketHandler
SocketHandler
using a standard socket.Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
protected SshEngine |
daemon |
protected SshEngineContext |
daemonContext |
protected SelectionKey |
key |
protected ProtocolEngine |
protocolEngine |
protected SelectorThread |
selectorThread |
protected SocketChannel |
socketChannel |
protected ByteBuffer |
socketDataIn |
protected ByteBuffer |
socketDataOut |
Constructor and Description |
---|
SocketConnection()
Construct the socket.
|
Modifier and Type | Method and Description |
---|---|
void |
closeConnection()
Close this socket connection.
|
SshEngineContext |
getDaemonContext()
Get the daemon process for this socket.
|
IdleStateManager |
getIdleStates()
Get the idle state manager.
|
int |
getInterestedOps()
Get the initial interested ops for this socket.
|
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.
|
int |
getPort()
Returns the local port to which the remote socket is connected.
|
ProtocolEngine |
getProtocolEngine()
Get the protocol engine for this socket.
|
SocketAddress |
getRemoteAddress()
Returns the address of the remote socket.
|
SocketChannel |
getSocketChannel()
Get the SocketChannel for this socket.
|
SelectorThread |
getThread()
Get the selector thread for this connection
|
void |
initialize(ProtocolEngine protocolEngine,
SshEngine daemon)
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(SelectableChannel channel,
SelectionKey key,
SelectorThread selectorThread)
The sockets channel has completed registration.
|
void |
setSelectionKey(SelectionKey key) |
void |
setThread(SelectorThread thread)
Set the selector thread for this connection
|
void |
setWriteState(boolean wantsWrite)
Sets the write state of the socket.
|
protected SocketChannel socketChannel
protected ProtocolEngine protocolEngine
protected SshEngineContext daemonContext
protected SelectorThread selectorThread
protected SelectionKey key
protected SshEngine daemon
protected ByteBuffer socketDataIn
protected ByteBuffer socketDataOut
protected boolean closed
public void initialize(ProtocolEngine protocolEngine, SshEngine daemon)
initialize
in interface SocketHandler
protocolEngine
- ProtocolEnginedaemon
- Daemonpublic void registrationCompleted(SelectableChannel channel, SelectionKey key, SelectorThread selectorThread)
registrationCompleted
in interface SelectorRegistrationListener
channel
- SelectableChannelkey
- SelectionKeyselectorThread
- SelectorThreadpublic void setSelectionKey(SelectionKey key)
setSelectionKey
in interface SelectionKeyAware
public void closeConnection()
public ProtocolEngine getProtocolEngine()
public SshEngineContext getDaemonContext()
public SocketAddress getLocalAddress()
public int getLocalPort()
public int getPort()
public SocketAddress getRemoteAddress()
public SocketChannel getSocketChannel()
public IdleStateManager getIdleStates()
public boolean isSelectorThread()
SelectorThread
?public void setWriteState(boolean wantsWrite)
wantsWrite
- booleanprotected boolean isConnected()
public SelectorThread getThread()
public int getInterestedOps()
getInterestedOps
in interface SocketHandler
public boolean processReadEvent()
processReadEvent
in interface SocketHandler
public boolean processWriteEvent()
processWriteEvent
in interface SocketHandler
public void setThread(SelectorThread thread)
setThread
in interface SocketHandler
thread
- SelectorThreadCopyright © 2016. All rights reserved.