Package java.nio.channels

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


                            "Address not bound: " + request.address );
                }
                else
                {
                    SelectionKey key = ch.keyFor( selector );
                    key.cancel();
                    selector.wakeup(); // wake up again to trigger thread death
                    ch.disconnect();
                    ch.close();
                }
            }
View Full Code Here


                }
                else
                {
                    SelectionKey key = ssc.keyFor( selector );

                    key.cancel();

                    selector.wakeup(); // wake up again to trigger thread death

                    ssc.close();
                }
View Full Code Here

            {
                entry.exception = e;
            }
            finally
            {
                key.cancel();
                if( entry.session == null )
                {
                    try
                    {
                        ch.close();
View Full Code Here

                {
                    exceptionMonitor.exceptionCaught( this, e );
                }
                finally
                {
                    key.cancel();
                }
            }
        }
    }
View Full Code Here

                            while(iter.hasNext())
                            {
                                key = (SelectionKey) iter.next();
                                if (key.isValid()&&key.interestOps()==0)
                                {
                                    key.cancel();
                                }
                            }
                            try
                            {
                                Thread.sleep(20)// tune or configure this
View Full Code Here

                                       
                    try
                    {
                        if (!key.isValid())
                        {
                            key.cancel();
                            SelectChannelEndPoint endpoint = (SelectChannelEndPoint)key.attachment();
                            if (endpoint != null)
                                endpoint.doUpdateKey();
                            continue;
                        }
View Full Code Here

    synchronized protected final void implCloseChannel() throws IOException {
        implCloseSelectableChannel();
        for (int i = 0; i < keyList.size(); i++) {
            SelectionKey key = (SelectionKey) keyList.get(i);
            if (null != key) {
                key.cancel();
            }
        }
    }

    /**
 
View Full Code Here

    logger.logWarn ("No handler for:" + sk);
      } else {
    // Ok, something is very bad here, try to shutdown the channel
    // and hope that we handle it ok elsewhere...
    logger.logError ("Bad handler for:" + sk + ": " + a);
    sk.cancel ();
    sk.channel ().close ();
      }
  }
  selected.clear ();
    }
View Full Code Here

    @Override
    protected void close(ServerSocketChannel handle) throws Exception {
        SelectionKey key = handle.keyFor(selector);
       
        if (key != null) {
            key.cancel();
        }
       
        handle.close();
    }
View Full Code Here

    @Override
    protected void destroy(NioSession session) throws Exception {
        ByteChannel ch = session.getChannel();
        SelectionKey key = session.getSelectionKey();
        if (key != null) {
            key.cancel();
        }
        ch.close();
    }

    @Override
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.