Package java.nio.channels

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


                tmpKey = null;
                tmpKey = channel.register(readSelector, SelectionKey.OP_READ);
                tmpKey.interestOps(tmpKey.interestOps() | SelectionKey.OP_READ);

                int code = readSelector.select(readTimeout);
                tmpKey.interestOps(tmpKey.interestOps() &
                    (~SelectionKey.OP_READ));

                if (code == 0) {
                    return 0; // Return on the main Selector and try again.
View Full Code Here


        int selectRetries = _networkManager.getSipLinkTimeoutRetries();
        long waitTime = _networkManager.getSipLinkTimeout();

        try {
            while ((selectRetries > 0) &&
                    ((sel = connectSel.select(waitTime)) < 1)) {
                selectRetries--;

                if (sel < 0) {
                    //
                    // something really wrong !
View Full Code Here

                int sel;
                int selectRetries = 0;
                long waitTime = _networkManager.getSipLinkTimeout();

                try {
                    while ((sel = writeSel.select(waitTime)) < 1) {
                        selectRetries++;

                        int left = message.remaining();

                        if (sel < 0) {
View Full Code Here

            Selector sel = NativeSelectorProvider.getInstance().openSelector();
            channel.configureBlocking(false);
            channel.socket().bind(address);
            channel.register(sel, SelectionKey.OP_ACCEPT, new ServerActor(channel, sel));

            while (sel.select() > 0) {
                Set<SelectionKey> keys = sel.selectedKeys();
                for (SelectionKey k : keys) {
                    Actor a = (Actor) k.attachment();
                    if (!a.rxready()) {
                        k.cancel();
View Full Code Here

      logger.l1("We are listening on " + bind.getHostString() + ":"
          + bind.getPort());
      Selector selector = Selector.open();
      server.register(selector, server.validOps());
      while (true) {
        selector.select();
        for (SelectionKey key : selector.selectedKeys()) {
          try {
            ServerSocketChannel channel = (ServerSocketChannel) key
                .channel();
            if (key.isValid()) {
View Full Code Here

                start = System.currentTimeMillis();
            }
            sender.setMessage(buf);
            int selectedKeys = 0;
            try {
                selectedKeys = selector.select(0);
            } catch (Exception e) {
                e.printStackTrace();
                continue;
            }
View Full Code Here

                start = System.currentTimeMillis();
            }
            sender.setMessage(buf);
            int selectedKeys = 0;
            try {
                selectedKeys = selector.select(0);
            } catch (Exception e) {
                e.printStackTrace();
                continue;
            }
View Full Code Here

    private class Worker implements Runnable {
        public void run() {
            Selector selector = DatagramAcceptorDelegate.this.getSelector();
            for (;;) {
                try {
                    int nKeys = selector.select();

                    registerNew();

                    if (nKeys > 0) {
                        processReadySessions(selector.selectedKeys());
View Full Code Here

    private class Worker implements Runnable {
        public void run() {
            Selector selector = getSelector();
            for (;;) {
                try {
                    int nKeys = selector.select();

                    registerNew();
                    doUpdateTrafficMask();

                    if (nKeys > 0) {
View Full Code Here

    private class Worker implements Runnable {
        public void run() {
            Selector selector = getSelector();
            for (;;) {
                try {
                    int nKeys = selector.select(1000);
                    doAddNew();
                    doUpdateTrafficMask();

                    if (nKeys > 0) {
                        process(selector.selectedKeys());
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.