public class MultiSocketClient extends AbstractSelector
address, cipherSuits, container, context, isClient, logger, needClientAuth, pendingData, port, protocols, selector, singleThreaded, taskWorker, toWorker, usingSSL
Constructor and Description |
---|
MultiSocketClient(java.net.InetAddress address,
int port,
AbstractPacketWorker packetWorker,
boolean usingSSL,
boolean needClientAuth,
int socketNo)
Create a TCPClient instance
|
Modifier and Type | Method and Description |
---|---|
protected void |
accept(java.nio.channels.SelectionKey key)
As this is the client implementation, it is NOT allowed to call this
method which is only useful for server implementations.
|
protected void |
connect(java.nio.channels.SelectionKey key)
Finish the connection to the server.
|
boolean |
handshakesFinished() |
protected void |
initConnection()
Initialize a client connection.
|
void |
invalidateSession(SocketIF socket)
Invalidate the SSL/TLS session (if any) on the underlying
SocketIF . |
boolean |
isConnected()
Returns whether or not this client is connected, if and only if it is
running (returns false otherwise).
|
void |
send(PacketIF packet)
|
addListener, closeSocket, handshakeComplete, isRunning, read, removeListener, run, send, setRunning, setupEngine, setupSSL, taskComplete, timeoutExpired, write
public MultiSocketClient(java.net.InetAddress address, int port, AbstractPacketWorker packetWorker, boolean usingSSL, boolean needClientAuth, int socketNo)
address
- The address to connect toport
- The port to connect topacketWorker
- The instance of packet worker to useusingSSL
- Whether we are using SSL/TLSneedClientAuth
- Whether this client should also authenticate with
the server.socketNo
- the number of sockets this client will havepublic void send(PacketIF packet)
PacketIF
over the this client's SocketIF
. Since
the client only has one socket, no socket parameter is necessary.packet
- The PacketIF to send through the associated SocketIF.AbstractSelector.send(ch.dermitza.securenio.socket.SocketIF,
java.nio.ByteBuffer)
public void invalidateSession(SocketIF socket)
SocketIF
. As this client implementation only has a single socket,
no parameter is needed.invalidateSession
in class AbstractSelector
socket
- The socket whose underlying
SSLSession
should be invalidatesAbstractSelector.invalidateSession(SocketIF)
public boolean handshakesFinished()
protected void initConnection() throws java.io.IOException
SocketChannel
, configures it to non-blocking, and registers it
with the underlying Selector
instance with an
OP_CONNECT SelectionKey
. If this client implementation is using
SSL/TLS, it also sets up the SSLEngine
, to be used.initConnection
in class AbstractSelector
java.io.IOException
- Propagates all underlying IOExceptions as thrown, to
be handled by the application layer.AbstractSelector.run()
protected void accept(java.nio.channels.SelectionKey key)
NoSuchMethodError
if it is called and
do nothing else.accept
in class AbstractSelector
key
- The selection key with the underlying SocketChannel
to
be acceptedAbstractSelector.run()
protected void connect(java.nio.channels.SelectionKey key)
SocketIF
is a secure
socket. Finally, after the connection has been established, the socket is
registered to the underlying Selector
, with a
SelectionKey
of OP_READ, signalling it is ready to read data.connect
in class AbstractSelector
key
- The selection key with the underlying SocketChannel
that needs a connection finalization.public boolean isConnected()