Package java.nio.channels

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


                            Log.ignore(e);
                        }
                    }
                       
                    long before=now;
                    int selected=selector.select(wait);
                    now = System.currentTimeMillis();
                    _idleTimeout.setNow(now);
                    _retryTimeout.setNow(now);
                    _selects++;
View Full Code Here


            return;
          }
          tmpKey = selectableChannel.register(writeSelector,
              SelectionKey.OP_WRITE);
        }
        if (writeSelector.select(1000) == 0) {
          attempts++;
          if (attempts > 2) {
            return;
          }
        } else {
View Full Code Here

              continue;
            }
            tmpKey = channel.register(writeSelector,
                SelectionKey.OP_WRITE);
          }
          if (writeSelector.select(1000) == 0) {
            if (attempts > 2) {
              throw new IOException("Client disconnected");
            }
          }
        }
View Full Code Here

    SelectionKey tmpKey = null;
    try {
      if (this.selectableChannel.isOpen()) {
        tmpKey = this.selectableChannel.register(readSelector, 0);
        tmpKey.interestOps(tmpKey.interestOps() | SelectionKey.OP_READ);
        int code = readSelector.select(500);
        tmpKey
            .interestOps(tmpKey.interestOps()
                & ~SelectionKey.OP_READ);
        if (code > 0) {
          do {
View Full Code Here

                                } else if ((operations & SelectionKey.OP_WRITE) != 0) {
                                    writeWouldBlock();
                                }
                            }
                        } else {
                            result[0] = selector.select();
                        }
                    } catch (IOException ioe) {
                        throw runtime.newRuntimeError("Error with selector: " + ioe.getMessage());
                    }
                }
View Full Code Here

            // this may block for a long time, upon return the
            // selected set contains keys of the ready channels
            try {
                events();
                socketTimeouts();
                int n = selector.select(getSelectorTimeout());
                if (n == 0) {
                    //there is a good chance that we got here
                    //because the TcpReplicationThread called
                    //selector wakeup().
                    //if that happens, we must ensure that that
View Full Code Here

    private class Worker implements Runnable {
        public void run() {
            Selector selector = DatagramAcceptorDelegate.this.selector;
            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 = SocketIoProcessor.this.selector;
            for (;;) {
                try {
                    int nKeys = selector.select(1000);
                    doAddNew();
                    doUpdateTrafficMask();

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

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

                    registerNew();

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

        public void run() {
            Selector selector = SocketConnector.this.selector;
            for (;;) {
                try {
                    int nKeys = selector.select(1000);

                    registerNew();

                    if (nKeys > 0) {
                        processSessions(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.