public final class PlainSocket extends java.lang.Object implements SocketIF
SocketIF
. As a plain socket behaves
no different than a SocketChannel
, this class can also be seen as a
wrapper with no additional functionality. Note that this class is declared as
final as it should NOT be extended. All required methods from
SocketIF
that deal with the secure implementation
(SecureSocket
) have no effect in
this implementation.
Constructor and Description |
---|
PlainSocket(java.nio.channels.SocketChannel channel)
Create a plain socket (i.e.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Pass-through implementation of
AbstractInterruptibleChannel.close() |
java.nio.channels.SelectableChannel |
configureBlocking(boolean block)
Pass-through implementation of
AbstractSelectableChannel.configureBlocking(boolean block) |
boolean |
connect(java.net.SocketAddress remote)
Pass-through implementation of
SocketChannel.connect(SocketAddress remote) |
boolean |
finishConnect()
Pass-through implementation of
SocketChannel.finishConnect() |
java.nio.channels.SocketChannel |
getSocket()
Returns the underlying
SocketChannel . |
boolean |
handshakePending()
Empty implementation satisfying
SocketIF.handshakePending() . |
void |
initHandshake()
Empty implementation satisfying
SocketIF.initHandshake() . |
void |
invalidateSession()
Empty implementation satisfying
SocketIF.invalidateSession() . |
void |
processHandshake()
Empty implementation satisfying
SocketIF.processHandshake() . |
int |
read(java.nio.ByteBuffer buffer)
Pass-through implementation of
SocketChannel.read(ByteBuffer buffer) |
java.nio.channels.SelectionKey |
register(java.nio.channels.Selector sel,
int ops)
Pass-through implementation of
SelectableChannel.register(Selector sel, int ops) |
void |
setTaskPending(boolean taskPending)
Empty implementation satisfying
SocketIF.setTaskPending(boolean taskPending) . |
void |
updateResult()
Empty implementation satisfying
SocketIF.updateResult() . |
int |
write(java.nio.ByteBuffer buffer)
Pass-through implementation of
SocketChannel.write(ByteBuffer buffer) |
public PlainSocket(java.nio.channels.SocketChannel channel)
SocketIF
interface. This instance has empty placeholder methods
for the SSL/TLS-related methods.channel
- The associated underlying SocketChannel
.public java.nio.channels.SelectableChannel configureBlocking(boolean block) throws java.io.IOException
AbstractSelectableChannel.configureBlocking(boolean block)
configureBlocking
in interface SocketIF
block
- If true then this channel will be placed in blocking mode;
if false then it will be placed in non-blocking modejava.io.IOException
- Propagated exceptions from the underlying
AbstractSelectableChannel.configureBlocking(boolean block)
implementation.public int read(java.nio.ByteBuffer buffer) throws java.io.IOException
SocketChannel.read(ByteBuffer buffer)
read
in interface SocketIF
buffer
- The buffer into which bytes are to be transferredjava.io.IOException
- Propagated exceptions from the underlying
SocketChannel.read(ByteBuffer buffer)
implementation.public int write(java.nio.ByteBuffer buffer) throws java.io.IOException
SocketChannel.write(ByteBuffer buffer)
public boolean connect(java.net.SocketAddress remote) throws java.io.IOException
SocketChannel.connect(SocketAddress remote)
connect
in interface SocketIF
remote
- The remote address to which this channel is to be connectedjava.io.IOException
- Propagated exceptions from the underlying
SocketChannel.connect(SocketAddress remote)
implementation.public java.nio.channels.SelectionKey register(java.nio.channels.Selector sel, int ops) throws java.nio.channels.ClosedChannelException
SelectableChannel.register(Selector sel, int ops)
register
in interface SocketIF
sel
- The selector with which this channel is to be registeredops
- The interest set for the resulting keyjava.nio.channels.ClosedChannelException
- Propagated exceptions from the underlying
SelectableChannel.register(Selector sel, int ops)
implementation.public java.nio.channels.SocketChannel getSocket()
SocketChannel
. This is done in order to
register the current socket with a Selector
, as only the
SocketChannel
implementation is allowed to be associated with a
Selector
.public void close() throws java.io.IOException
AbstractInterruptibleChannel.close()
public boolean finishConnect() throws java.io.IOException
SocketChannel.finishConnect()
finishConnect
in interface SocketIF
java.io.IOException
- Propagated exceptions from the underlying
SocketChannel.finishConnect()
implementation.public void processHandshake()
SocketIF.processHandshake()
. No
handshaking is present on a PlainSocket
. This method has NO
effect.processHandshake
in interface SocketIF
SecureSocket.processHandshake()
public boolean handshakePending()
SocketIF.handshakePending()
. No
handshaking is present on a PlainSocket
. This method has NO
effect.handshakePending
in interface SocketIF
SecureSocket.handshakePending()
public void updateResult()
SocketIF.updateResult()
. No
SSLEngineResult
is present on a
PlainSocket
. This method has NO effect.updateResult
in interface SocketIF
SecureSocket.updateResult()
public void setTaskPending(boolean taskPending)
SocketIF.setTaskPending(boolean taskPending)
. No task is pending
on a PlainSocket
. This method has NO effect.setTaskPending
in interface SocketIF
taskPending
- unusedSecureSocket.setTaskPending(boolean)
public void invalidateSession()
SocketIF.invalidateSession()
. No
SSLSession
is present on a PlainSocket
.
This method has NO effect.invalidateSession
in interface SocketIF
public void initHandshake() throws java.io.IOException
SocketIF.initHandshake()
. No
handshaking is present on a PlainSocket
. This method has NO
effect.initHandshake
in interface SocketIF
java.io.IOException
- Never thrown.SecureSocket.initHandshake()