Code example for ServerSocketChannel

Methods: acceptkeyFor

0
     * {@inheritDoc} 
     */ 
    @Override 
    protected NioSession accept(IoProcessor<NioSession> processor, ServerSocketChannel handle) throws Exception {
 
        SelectionKey key = handle.keyFor(selector);
 
        if ((key == null) || (!key.isValid()) || (!key.isAcceptable())) {
            return null; 
        } 
 
        // accept the connection from the client 
        SocketChannel ch = handle.accept();
 
        if (ch == null) {
            return null; 
        } 
 
        return new NioSocketSession(this, processor, ch);
    }