Examples of interestOps()


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

                        if ( close ) {
                            key.interestOps(0);
                            ka.interestOps(0); //avoid duplicate stop calls
                            processKey(key,ka);
                        } else if (isTimedout) {
                            key.interestOps(0);
                            ka.interestOps(0); //avoid duplicate timeout calls
                            cancelledKey(key, SocketStatus.TIMEOUT);
                        }
                    } else if (ka.isAsync() || ka.isComet()) {
                        if (close) {
View Full Code Here

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

                            ka.interestOps(0); //avoid duplicate timeout calls
                            cancelledKey(key, SocketStatus.TIMEOUT);
                        }
                    } else if (ka.isAsync() || ka.isComet()) {
                        if (close) {
                            key.interestOps(0);
                            ka.interestOps(0); //avoid duplicate stop calls
                            processKey(key,ka);
                        } else if (!ka.isAsync() || ka.getTimeout() > 0) {
                            // Async requests with a timeout of 0 or less never timeout
                            long delta = now - ka.getLastAccess();
View Full Code Here

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

                    }
                    // is there data to read on this channel?
                    if (key.isReadable()) {
                        readDataFromSocket(key);
                    } else {
                        key.interestOps(key.interestOps() & (~SelectionKey.OP_WRITE));
                    }

                    // remove key from selected set, it's been handled
                    it.remove();
                }
View Full Code Here

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

                    }
                    // is there data to read on this channel?
                    if (key.isReadable()) {
                        readDataFromSocket(key);
                    } else {
                        key.interestOps(key.interestOps() & (~SelectionKey.OP_WRITE));
                    }

                    // remove key from selected set, it's been handled
                    it.remove();
                }
View Full Code Here

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

        try {
          sb.append("; ready="
              + Integer.toBinaryString(sk.readyOps()));
          sb.append("; interest="
              + Integer.toBinaryString(sk.interestOps()));
        } catch (CancelledKeyException e) {
          sb.append("; cancelled");
        }
      }
    }
View Full Code Here

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

            if(!key.isValid()) {
                NIOAttachment attachment = (NIOAttachment)key.attachment();
                attachment.close(new IOException("Connection closed"));

            // close the server socket
            } else if((key.interestOps() & SelectionKey.OP_ACCEPT) != 0) {
                try {
                    ServerSocketChannel server = (ServerSocketChannel)key.channel();
                    server.close();
                    key.cancel();
                } catch(IOException e) {
View Full Code Here

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

        synchronized (this.pendingChanges)
        {
          for (NioChangeRequest change : this.pendingChanges)
          {
            SelectionKey key = change.socket.keyFor(this.selector);
            key.interestOps(change.ops);
          }
          this.pendingChanges.clear();
        }

        // Wait for an event one of the registered channels
View Full Code Here

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

          }

          if (key.isAcceptable()) {
            handleAccept();
          } else {
            LOGGER.warn("Unexpected state in select! " + key.interestOps());
          }
        }
      } catch (IOException e) {
        LOGGER.warn("Got an IOException while selecting!", e);
      }
View Full Code Here

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

            handleRead(key);
          } else if (key.isWritable()) {
            // deal with writes
            handleWrite(key);
          } else {
            LOGGER.warn("Unexpected state in select! " + key.interestOps());
          }
        }
      } catch (IOException e) {
        LOGGER.warn("Got an IOException while selecting!", e);
      }
View Full Code Here

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

    private void notifyWriteTimeout(SocketSessionImpl session,
            long currentTime, long writeTimeout, long lastIoTime) {
        SelectionKey key = session.getSelectionKey();
        if (writeTimeout > 0 && (currentTime - lastIoTime) >= writeTimeout
                && key != null && key.isValid()
                && (key.interestOps() & SelectionKey.OP_WRITE) != 0) {
            session.getFilterChain().fireExceptionCaught(session,
                    new WriteTimeoutException());
        }
    }
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.