protected void accept(SelectionKey key) {
ServerSocketChannel ch = (ServerSocketChannel) key.channel();
SocketChannel s;
try {
while ((s = ch.accept()) != null) {
long t0 = evtAccepts.time();
s.configureBlocking(false);
NetCtx atta = ctxFactory.create(s, null,this);
s.register(selector, OP_READ, atta);
log.traceNio(key, "accept()", "AFTER");
if (sslContext != null) {
TlsContext tctx = new TlsContext();
tctx.setSslEngine(sslContext.createSSLEngine());
tctx.getSslEngine().setUseClientMode(false);
tctx.getSslEngine().beginHandshake();
tctx.setSslState(HANDSHAKE);
atta.setTlsContext(tctx);
log.traceNio(key, "accept()", "SSL");
}
evtAccepts.call(t0);
}
} catch (Exception e) {
log.error("accept incoming request", e);
evtAccepts.error();
}
}