public class TCPServer extends AbstractSelector
AbstractSelector
. This implementation
is purely non-blocking and can handle both PlainSocket
s and
SecureSocket
s.address, cipherSuits, container, context, isClient, logger, needClientAuth, pendingData, port, protocols, selector, singleThreaded, taskWorker, toWorker, usingSSL
Constructor and Description |
---|
TCPServer(java.net.InetAddress address,
int port,
AbstractPacketWorker packetWorker,
boolean usingSSL,
boolean needClientAuth)
Create a TCPServer instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
accept(java.nio.channels.SelectionKey key)
Accepts incoming connections and binds new non-blocking
SocketIF
instances to them. |
protected void |
connect(java.nio.channels.SelectionKey key)
As this is the server implementation, it is NOT allowed to call this
method which is only useful for client implementations.
|
protected void |
initConnection()
Initialize a server connection.
|
void |
send(SocketIF sc,
PacketIF packet)
|
addListener, closeSocket, handshakeComplete, invalidateSession, isRunning, read, removeListener, run, send, setRunning, setupEngine, setupSSL, taskComplete, timeoutExpired, write
public TCPServer(java.net.InetAddress address, int port, AbstractPacketWorker packetWorker, boolean usingSSL, boolean needClientAuth)
address
- The address to bind toport
- The port to listen onpacketWorker
- The instance of packet worker to useusingSSL
- Whether we are using SSL/TLSneedClientAuth
- Whether we need clients to also authenticatepublic void send(SocketIF sc, PacketIF packet)
sc
- The SocketIF to send the packet through.packet
- The PacketIF to send through the associated SocketIF.AbstractSelector.send(ch.dermitza.securenio.socket.SocketIF,
java.nio.ByteBuffer)
protected void initConnection() throws java.io.IOException
ServerSocketChannel
, configures it to non-blocking, binds it to
the specified (if any) host and port, sets the specified backlog and
registers it with the underlying Selector
instance with an OP_ACCEPT SelectionKey
.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)
SocketIF
instances to them. If this server implementation is using SSL/TLS, it
also sets up the SSLEngine
, to be used.accept
in class AbstractSelector
key
- The selection key with the underlying SocketChannel
to
be acceptedAbstractSelector.run()
protected void connect(java.nio.channels.SelectionKey key)
NoSuchMethodError
if it is called and
do nothing else.connect
in class AbstractSelector
key
- The selection key to be used for connecting.AbstractSelector.run()