Package java.nio.channels

Examples of java.nio.channels.SelectionKey.readyOps()


      throws IOException {
    for (Iterator<SelectionKey> i = selectedKeys.iterator(); i.hasNext();) {
      SelectionKey k = i.next();
      i.remove();
      try {
        int readyOps = k.readyOps();
        if ((readyOps & SelectionKey.OP_READ) != 0 || readyOps == 0) {
          if (!read(k)) {
            // Connection already closed - no need to handle write.
            continue;
          }
View Full Code Here


        }
        for (Iterator<SelectionKey> i = selectedKeys.iterator(); i.hasNext();) {
            SelectionKey k = i.next();
            i.remove();
            try {
                int readyOps = k.readyOps();
                if ((readyOps & SelectionKey.OP_READ) != 0 || readyOps == 0) {
                    if (!read(k)) {
                        // Connection already closed - no need to handle write.
                        continue;
                    }
View Full Code Here

       
        Iterator it = selector.selectedKeys().iterator();
        while (it.hasNext()) {
            SelectionKey sk = (SelectionKey) it.next();
            it.remove();
            int readyOps = sk.readyOps();
            sk.interestOps(sk.interestOps() & ~readyOps);
            NioSender sender = (NioSender) sk.attachment();
            try {
                if (sender.process(sk,waitForAck)) {
                    completed++;
View Full Code Here

                        SelectionKey sk = iterator.next();
                        KeyAttachment attachment = (KeyAttachment)sk.attachment();
                        try {
                            attachment.access();
                            iterator.remove();
                            sk.interestOps(sk.interestOps() & (~sk.readyOps()));
                            if ( sk.isReadable() ) {
                                countDown(attachment.getReadLatch());
                            }
                            if (sk.isWritable()) {
                                countDown(attachment.getWriteLatch());
View Full Code Here

        Iterator<SelectionKey> it = selector.selectedKeys().iterator();
        while (it.hasNext()) {
            SelectionKey sk = it.next();
            it.remove();
            int readyOps = sk.readyOps();
            sk.interestOps(sk.interestOps() & ~readyOps);
            NioSender sender = (NioSender) sk.attachment();
            try {
                if (sender.process(sk,waitForAck)) {
                    completed++;
View Full Code Here

            assertEquals(1, count);
            Set<SelectionKey> selectedKeys = selector.selectedKeys();
            assertEquals(1, selectedKeys.size());
            SelectionKey key = selectedKeys.iterator().next();
            assertEquals(ssc.keyFor(selector), key);
            assertEquals(SelectionKey.OP_ACCEPT, key.readyOps());
            // select again, it should return 0
            count = selectOnce(type, timeout);
            assertEquals(0,count);
            // but selectedKeys remains the same as previous
            assertSame(selectedKeys, selector.selectedKeys());
View Full Code Here

            assertEquals(1, count);
            Set<SelectionKey> selectedKeys = selector.selectedKeys();
            assertEquals(1, selectedKeys.size());
            SelectionKey key = selectedKeys.iterator().next();
            assertEquals(sc.keyFor(selector), key);
            assertEquals(SelectionKey.OP_CONNECT, key.readyOps());
            // select again, it should return 0
            count = selectOnce(type, timeout);
            assertEquals(0, count);
            // but selectedKeys remains the same as previous
            assertSame(selectedKeys, selector.selectedKeys());
View Full Code Here

            assertEquals(1, count);
            Set<SelectionKey> selectedKeys = selector.selectedKeys();
            assertEquals(1, selectedKeys.size());
            SelectionKey key = selectedKeys.iterator().next();
            assertEquals(sc.keyFor(selector), key);
            assertEquals(SelectionKey.OP_READ, key.readyOps());
            // select again, it should return 0
            count = selectOnce(type, timeout);
            assertEquals(0, count);
            // but selectedKeys remains the same as previous
            assertSame(selectedKeys, selector.selectedKeys());
View Full Code Here

            assertEquals(1, count);
            Set<SelectionKey> selectedKeys = selector.selectedKeys();
            assertEquals(1, selectedKeys.size());
            SelectionKey key = selectedKeys.iterator().next();
            assertEquals(sc.keyFor(selector), key);
            assertEquals(SelectionKey.OP_WRITE, key.readyOps());
            // select again, it should return 0
            count = selectOnce(type, timeout);
            assertEquals(0, count);
            // but selectedKeys remains the same as previous
            assertSame(selectedKeys, selector.selectedKeys());
View Full Code Here

      synchronized (keys) {
        for (Iterator<SelectionKey> iter = keys.iterator(); iter.hasNext();) {
          SelectionKey selectionKey = iter.next();
          iter.remove();
          try {
            int ops = selectionKey.readyOps();
            if ((ops & SelectionKey.OP_READ) == SelectionKey.OP_READ) {
              if (selectionKey.attachment() == tcp) {
                while (true) {
                  Object object = tcp.readObject(this);
                  if (object == null) break;
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.