Code example for SelectionKey

Methods: channelisAcceptableisValid

0
         * @return The next SocketChannel in the iterator 
         */ 
        public ServerSocketChannel next() {
            SelectionKey key = iterator.next();
             
            if ( key.isValid() && key.isAcceptable() ) {
                return (ServerSocketChannel) key.channel();
            } 
 
            return null; 
        } 
 
        /** 
         * Remove the current SocketChannel from the iterator  
         */ 
        public void remove() { 
            iterator.remove();
        } 
    } 
}