Examples of selectedKeys()


Examples of java.nio.channels.Selector.selectedKeys()

        channel.register(selector, SelectionKey.OP_ACCEPT, acceptHandler);

        int n;
        while((n = selector.select()) > 0) {
            // Someone is ready for I/O, get the ready keys
            Set<SelectionKey> selectedKeys = selector.selectedKeys();
            final Iterator<SelectionKey> keyItor = selectedKeys.iterator();
            while(keyItor.hasNext()) {
                SelectionKey key = keyItor.next();
                keyItor.remove();
                // The key indexes into the selector so you
View Full Code Here

Examples of java.nio.channels.Selector.selectedKeys()

                        out_channel.configureBlocking(false);
                        in_channel.register(sel, SelectionKey.OP_READ);
                        out_channel.register(sel, SelectionKey.OP_READ);
                       
                        while (sel.select() > 0) {
                            ready_keys=sel.selectedKeys();
                            for (Iterator it=ready_keys.iterator(); it.hasNext();) {
                                key=(SelectionKey) it.next();
                                it.remove(); // remove current entry (why ?)
                                tmp=(SocketChannel) key.channel();
                                if (tmp == null) {
View Full Code Here

Examples of java.nio.channels.Selector.selectedKeys()

            key.interestOps(key.interestOps()|real_ops);
        }

        while(selector.select() == 0);

        for (Iterator i = selector.selectedKeys().iterator(); i.hasNext(); ) {
            SelectionKey skey = (SelectionKey) i.next();
            if ((skey.interestOps() & skey.readyOps() & (SelectionKey.OP_WRITE)) != 0) {
                if(skey.attachment() == descriptor) {
                    return true;
                }
View Full Code Here

Examples of java.nio.channels.Selector.selectedKeys()

            key.interestOps(key.interestOps()|real_ops);
        }

        while(selector.select() == 0);

        for (Iterator i = selector.selectedKeys().iterator(); i.hasNext(); ) {
            SelectionKey skey = (SelectionKey) i.next();
            if ((skey.interestOps() & skey.readyOps() & (SelectionKey.OP_READ | SelectionKey.OP_ACCEPT)) != 0) {
                if(skey.attachment() == descriptor) {
                    return true;
                }
View Full Code Here

Examples of java.nio.channels.Selector.selectedKeys()

           }
          
           List r = new ArrayList();
           List w = new ArrayList();
           List e = new ArrayList();
           for (Iterator i = selector.selectedKeys().iterator(); i.hasNext(); ) {
               SelectionKey key = (SelectionKey) i.next();
               if ((key.interestOps() & key.readyOps()
                       & (SelectionKey.OP_READ|SelectionKey.OP_ACCEPT|SelectionKey.OP_CONNECT)) != 0) {
                   r.add(key.attachment());
                   pending.remove(key.attachment());
View Full Code Here

Examples of java.nio.channels.Selector.selectedKeys()

                    registerNew();
                    doUpdateTrafficMask();

                    if (nKeys > 0) {
                        processReadySessions(selector.selectedKeys());
                    }

                    flushSessions();
                    cancelKeys();
View Full Code Here

Examples of java.nio.channels.Selector.selectedKeys()

                    int nKeys = selector.select(1000);

                    registerNew();

                    if (nKeys > 0) {
                        processSessions(selector.selectedKeys());
                    }

                    processTimedOutSessions(selector.keys());

                    if (selector.keys().isEmpty()) {
View Full Code Here

Examples of java.nio.channels.Selector.selectedKeys()

                    int nKeys = selector.select();

                    registerNew();

                    if (nKeys > 0) {
                        processReadySessions(selector.selectedKeys());
                    }

                    flushSessions();
                    cancelKeys();
View Full Code Here

Examples of java.nio.channels.Selector.selectedKeys()

                // from acquiring its lock.
            }
            try {
                int selectedKeyCount = selector.select(500);
                if (selectedKeyCount > 0) {
                    processSelectedKeys(selector.selectedKeys());
                }

                if (selector.keys().isEmpty()) {
                    if (shutdown) {
                        try {
View Full Code Here

Examples of java.nio.channels.Selector.selectedKeys()

                    // from acquiring its lock.
                }
                try {
                    int selectedKeyCount = selector.select(500);
                    if (selectedKeyCount > 0) {
                        processSelectedKeys(selector.selectedKeys());
                    }

                    if (selector.keys().isEmpty()) {
                        if (shutdown) {
                            try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.